HI everyone ! i am very new to c#.
please can anybody explain why i can't access c# list in button click event when c# list is declared in page_load event ?
You need to do some reading about variable scope. Every variable only exists inside the block it is declared in, with the (sort of) exception of a type field declared public. If you declare a variable inside a method then that variable exists only inside that method. If you want to be able to access the same variable from multiple methods then it needs to be declared outside all of them.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.