Programming Language: C#
Type: Tutorial
Level: Beginners
Topic Category: General Programming
Main Series: Introduction to programming in C# and the .NET framework
Topic Title: Fundamental Types in .NET & C#
Introduction
The .NET framework is special in that, unlike other programming framework, it does have a standard library of classes that is shared amongst all programming languages (PLs) targeting the .NET Framework. That means that you learn these type libraries regardless of the PL you intend to use (and regardless of the platform as the mono framework is available for other platforms)
It is good to learn the classes within the context of your PL of choice however. In this article we introduce you to the most basic types/classes in the .NET framework (I call them the "Fundamental Types").
The Mother Class: Object
Within the whole .NET framework's common type system (CTS), there's a class that all other classes are inherited from either directly or indirectly. When you declare a new class, it is also inherited from this class in some way. It is the "Object" class.
For those not familiar with inheritance, it suffices to say that no matter what is the object you are manipulating, and no matter what is the data type you are working with, it is an Object. In other words, if we declared an object reference, we can reference any object of any class. For example, all the following statements are fine and correct:
object o1 = 10;
object o2 = 'd';
object o3 = "Some string";
object o4 = DateTime.Now;
object o5 = new Student(2546, 2005, "John Doe", new DateTime(1985, 1, 1));
object o6 = 3.556;
object o7 = new int[] {1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89};
object o8 = new Hashtable();
object o9 = new Button();
In some since, you might think of this type as being a "super-type" that can behave on behalf of all other types. For those familiar with other PLs such as VB or Basic or with Javascript, the Object type is the closest thing you'll get to a var or variant variable in those languages.
Type: Tutorial
Level: Beginners
Topic Category: General Programming
Main Series: Introduction to programming in C# and the .NET framework
Topic Title: Fundamental Types in .NET & C#
Introduction
The .NET framework is special in that, unlike other programming framework, it does have a standard library of classes that is shared amongst all programming languages (PLs) targeting the .NET Framework. That means that you learn these type libraries regardless of the PL you intend to use (and regardless of the platform as the mono framework is available for other platforms)
It is good to learn the classes within the context of your PL of choice however. In this article we introduce you to the most basic types/classes in the .NET framework (I call them the "Fundamental Types").
The Mother Class: Object
Within the whole .NET framework's common type system (CTS), there's a class that all other classes are inherited from either directly or indirectly. When you declare a new class, it is also inherited from this class in some way. It is the "Object" class.
For those not familiar with inheritance, it suffices to say that no matter what is the object you are manipulating, and no matter what is the data type you are working with, it is an Object. In other words, if we declared an object reference, we can reference any object of any class. For example, all the following statements are fine and correct:
object o1 = 10;
object o2 = 'd';
object o3 = "Some string";
object o4 = DateTime.Now;
object o5 = new Student(2546, 2005, "John Doe", new DateTime(1985, 1, 1));
object o6 = 3.556;
object o7 = new int[] {1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89};
object o8 = new Hashtable();
object o9 = new Button();
In some since, you might think of this type as being a "super-type" that can behave on behalf of all other types. For those familiar with other PLs such as VB or Basic or with Javascript, the Object type is the closest thing you'll get to a var or variant variable in those languages.