13. C# - Public Access Modifier
Access modifier allows or restricts access to types or variables etc.
Adding a "public" in front of a type,method,statement will let it be access outside of the scope it is within.
Format:
[ACCESS MODIFIER] [TYPE] [VARIABLE_NAME]
Example for Variable:
public String Dog;
Dog = "Benny";
Example for Methods/Functions:
public void MethodName(){
whatever inside
}
// methods/functions need to return a value. If dont need to return, then add "void" in front of method's name.
Comments
Post a Comment