Friday February 5th

1 Kicks

Classes, Structs, and Objects

Explains these C# fundamentals and how to best use these C# types. Excerpt: The ability to invent your own types is tantamount to object-oriented systems. The cool thing is that, since even the built-in types of the language are plain-old CLR objects, the objects you create are on a level playing field with the built-in types. In other words, the built-in types don’t have special powers that you cannot muster. The cornerstone for creating these types is the class definition. Class definitions, using the C# class keyword, define the internal state and the behaviors associated with the objects of that class’s type. The internal state of an object is represented by the fields that you declare within the class, which can consist of references to other objects, or values. Sometimes, but rarely, you will hear people describe this as the "shape" of the object, since the instance field definitions within the class define the memory footprint of the object on the heap. The objects created from a class encapsulate the data fields that represent the internal state of the objects, and the objects can tightly control access to those fields. The behavior of the objects is defined by implementing methods, which you declare and define within the class definition. By calling one of the methods on an object instance, you initiate a unit of work on the object. That work can possibly modify the internal state of the object, inspect the state of the object, or anything else for that matter.


Commenting on Stories is limited for now and will open up to those recommended by the community. Learn how
Loading DotNetKicks...
brought to you by the Kicks Network