Possible Duplicate:
C# Automatic Properties
Hello,
I have recently moved towards .net (c#) platform from Java. Here I don't face much problem yet... anyway I 'm messed up with
property{get, set}method. Actually I could not get up the exact meaning of these (property) according to me the same job of initializing variables or field or state of object can be done using methods. where we can declare fields as private and can access them using public method of same class.
Well one simple thing I am not a programmer or employee but a general students of Computer science aimed to become a programmer as full time career.
- so many thanks all of you in-advance for assisting me.
property{get, set}Using Properties removes the method calls for setting values and getting their values for private members. Like:
private int number = 0;
public int Number { get{ return number;} set{number = value;}}
now all you have to do is make an object, and instead of calling functions/methods to access the number, you can do:
ObjectCreated.Number = 100;
Console.WriteLine(ObjectCreated.Number);
implicitly, Number will set number = 100, and next line, would fetch the number which is 100.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With