The concept of objects and classes is almost the same in C# as in Java. Object is the ultimate base class of all other types. New reference types can be defined using the 'class' and 'interface'
declarations. Delegate is another reference type. It is like a functions pointer as in C and C++. Reference types actually hold the value of a memory address occupied by the object they reference.
We declare a class in the same way as we do in Java and C++. Consider the following piece of code:
//program code goes here....
Some Points to Remember:
We will continue our discussion on classes and objects in the next lesson.
- using statement is used to import external code(namespaces), as we use the import keyword in Java.
- The keyword namespace is just like the package keyword in Java.
- Every class has to be a part of a namespace. The above class belongs to the namespace helloworld.
- Unlike C++ there are no global functions or variables. Everything has to be the part of a class.
- Unlike Java and C++ a class can be declared as partial, which means that the class is written in more than 1 .cs files.
Next >>> Lesson No. 15: C# Objects and Classes 2