3
Answers

what is the scope of public int x?

Photo of Valerie Meunier

Valerie Meunier

2y
607
1

Hi

I have two webforms. In the first, i put a public field x, but it's unknown in the second webform, despite the fact is public (i know that session and viewstate allow to pass from one webform to another but that's not the point here) and my question is: apparently, the scope of x is limited to its webform, despite the fact it's public. Why? And what's then the difference between internal and public here?

Thanks

public partial class WebForm1 : System.Web.UI.Page
    {
        public int x = 5;
        protected void Page_Load(object sender, EventArgs e)
        {

           .......

        }
    }

Answers (3)