1

im learning computer science and in all my cs files i have that line of code that i do not understand the purpose for...i understood that it waits for the page to load or something but what is void and protected all about?

protected void Page_Load

is a the piece of code

2
  • If it's a line of code, presumably it has a specific language. You may want to add a tag specifying that :-)
    – paxdiablo
    Commented Jun 7, 2014 at 16:14
  • I tagged it c#, since your said you "cs" files. That isn't the whole line, is it?
    – clcto
    Commented Jun 7, 2014 at 16:15

2 Answers 2

4

protected is an access modifier and it means that access is limited to the containing class or types derived from the containing class.

void is the return type of the method and it means it it does not return anything.

As mentioned by other Page_Loadre is the event method triggered when the current page is is loaded so this method doesn't return anything as well does need to be accessed by other classes other than the class it resides. (sometimes however you may need to change this modifier).

Here may have a general look about access modifiers

1

It's basically a method that will get called once the page has loaded. 'Protected' means that it's visible from within the class and any classes that inherits it, 'void' means it has no return value, and 'Page_Load' is the name of the method.

This method will, most probably, be handling an 'event' that gets fired once the page has loaded and this occurs when all the controls on the page have been created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.