Struct (Value Types)
Classe Will be used to implement most objects.
Somtimes however, it may be desirable to create an object that behavves like one of the references. in that case, a value type used, wich is done by declaring a Struct in C#.
structs act similarly to classes, but with a few added restrictions. they can't inherit form any other type (thought they implicitly inherit form Object), and other classes can't inherit from them.
In a graphics system, a value class could be used to encapsulate a point.
Here's how it would be declared
for value types,new create an object on the stack and then calls the appropriate constructor.
In the Console.writeline() we type the value or Start, and its (5,5)
well thats it today, I hope you now knows a lil' bit about the Constructor and the use for it.
|All times are GMT +5.5. The time now is 06:37.|