As I mentioned earlier, object-oriented programming is all about objects. To make objects you create classes. You can think of classes as a factory for building objects. Inside a class you have the attributes and methods of the class. Attributes and methods have a number of access modifiers. This defines encapsulation. That is a big word that means data and methods belong inside the class.
Two examples of access modifiers are private and public. Private means that only methods and attributes inside the class can use it. If you have a variable that is defined private such as:
private int value;
Only items in a class can access that variable. The same is true for methods:
private void method()
{
}
That method can only be called inside the class. Public on the other hand means that the variable can be modified outside of the object. If you remember the Hello, World! program you used Console.WriteLine("Hello, World!"); the reason you were able to is that WriteLine is public.
I just wanted to say that before I post the next tutorial. It will make things a little easier. Just one more thing to say, be default when you make a variable or a method inside a class it is considered private. Hopefully, I will have the tutorial I was talking about ready and on my website. Hope you have a wonderful Thursday!
-----------------------------
Proud member of Dream.In.Code
Thursday, May 7, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment