在C#下面粗略示例代碼我對宣佈條件的字符串,我無法訪問它的是支具在C#全局聲明一個字符串
if(//some condition)
{
string value1 = "something";
}
//push to database value1
在上面的代碼編譯說:The name 'value1' does not exists in the current context
我需要以這樣一種方式聲明value1
,它必須在整個頁面中進行訪問。我試過protected value1
,但那也不起作用。我討厭把它作爲一個單獨的課程來使用。無論如何要宣佈全球?