Hi
I am going through the video tutes here, and reading the supplementary material in the PDF, but im still confused about the differences between creating a public, or private method.
what is the difference are they both used, or is one preferred to the other
thanks for any tips.
DA

public vs. private methods
smitprabhu
hi,
think of it as securety permissions and visiblity to others for example if you have
private stuff >>> then we can't see and we don't have persmission to know it like your visa card number for example
public stuff >>> is like your post now we have permission and can see it
protected stuff >>> just you and your family who can know it and noother one have permission to know it
when you build a class or method you have to determin the security of this part use private with the methods or fields that will just be used within your class and no other classes have permission to see it
use public with the things that you want your class to share it with all classes
use protected with stuff that you want only the family of this class can see though inheritance
hope that helps
Eddie Cheung
Hi,
it depends if:
1)you want to make these methods accessible without restriction => Public
(remember that the Main method is declared public so that Main() can be invoked from any .NET runtime enviroment)
2)you want to make these methods accessible ONLY by the instance of the class that declares the method => Private
(by the container only. so that it's known as the least generous access modifier)
Simon Smith
Dan,
Private methods can only be called by other methods in the Class. Only that class can see the method.
Public methods can be seen and called by other Classes in your project.