c# - When should I use public/private/static methods? -


I'm new to C #. For this moment, I was making every universal variable - the public stable. All of my methods are public, so I can access them from other classes.

I have read so much that I have less public stagnant ways, better then. Therefore, I rewrite my applications by putting all the code in one category - form class. Now all my methods are private and there is no steady way.

My question: What should I do, form class dump to keep everything in my class?

When should I use the public, when private and when private / public stable?

I find public methods in the form of 'opposition' because they can be unconnected, but I doubt it. My public methods can also be disjointed. Private private is so 'private'?

Edit : I'm not saying how to prevent my program from being inconvenient, I'm asking that I'm stable, private and public. Even more: There is a problem in putting all the code in Form C so do not I need to use public methods?

  class account {private int pin = 10 0} Examples of personal use:  

; Public Ent Pin {Get {Return Pin; Public on the other hand, there is no restriction on reaching public members, so when such things which are reaching the user should be public.

On the other hand there is no relation with both the stable, because it is not in the way of dealing with the permission, but on the other hand there is a steady or kind declaration. If the word is applied to the stable class then each member in the class must be declared stable.

Example to use the static:

  Static int-yayar = 1985  

You will see all the modifiers in C # Give more details and how to use examples


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -