Valerie Meunier

Valerie Meunier

  • 954
  • 693
  • 72.5k

what is the scope of public int x?

Feb 14 2023 9:45 AM

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)