다음 코드를 사용합니다.이 코드에서는 eventHandling을 사용하여 1,2,3 등의 문자열 값을 얻을 수 있습니다. 값은 중요하지 않습니다. now.What 필요한 지금은 아래 주어진 함수로 myfun()
같은 page_load 이벤트 외부에서이 문자열 값을 액세스 할 수 있습니다. 내가 어떻게 acheive.로컬 변수 값을 C로 글로벌하게합니다. #
protected void Page_Load(object sender, EventArgs e)
{
hfm mymaster = (hfm)Page.Master;
lcont lc = mymaster.getlcont();
lc.myevent += delegate(string st)
{
//slbl.Text = st;
string str =st;
}
}
protectd void myfun()
{
//i want to access the string value "st" here.
}
위임 범위가 아닌 클래스 범위에서 정의하거나 'myfun()'에 매개 변수로 전달하십시오. –