0
What does it means when a method is started using "private"in c#?
Somewhere I've seen method declaration like "private method (args)", what does private means here?
2 Réponses
+ 2
private means that the method used is available for the current class only, and if you use a private variable inside a method it will be restricted to the containing method.
Which means that [private] is used to restrict access to the argument/function to the container
in example.
A method that is private like "private void Test () {}" will be restricted to the class containing it only.
A variable that is private inside a method like "private string name;" can only be accessed or changed in the current method.
+ 1
when a method is private you can only use it in tgat class ,attempt to use that method outside of that class produces an error