static and non static method
For "static" you don't need an instance of the class to use them, you can
just use MyClass.FunctionName();
It makes sense in some circumstances, would you really want to create an
instance of the Math class just to perform some Cosine operations, or would
you prefer just to do Math.Cosine()?
As for members, if you make a member (such as Int32) static it will be
shared amongst all instances of your class (including instances of descended
What is the difference between class and structure?
Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public.
Class: Class is a successor of Structure. By default all the members inside the class are private.
int and int32
Int32 is the System.Int32 class, while int is an alias for System.Int32.
The same applies for String (uppercase S) which is System.String, while string (lowercase S) is an alias for System.String.
So basically int is the same thing as Int32, and string is the same thing as Int32. It's down to user's preference which one to use but most prefer to use int and string as they are easier to type and more familiar among C++ programmers.
Static class and non static class
A static class is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated. In other words, you cannot use the new keyword to create a variable of the class type. Because there is no instance variable, you access the members of a static class by using the class name itself.
The main features of a static class are:
* They only contain static members.
* They cannot be instantiated.
* They are sealed.
* They cannot contain Instance Constructors
boxing and unboxing
Boxing and unboxing is a essential concept in C#?s type system. With Boxing and unboxing one can link between value-types and reference-types by allowing any value of a value-type to be converted to and from type object. Boxing and unboxing enables a unified view of the type system wherein a value of any type can ultimately be treated as an object.
Converting a value type to reference type is called Boxing.Unboxing is an explicit operation.
C# provides a ?unified type system?. All types?including value types?derive from the type object. It is possible to call object methods on any value, even values of ?primitive? types such as int.
Boxing and unboxing enable value types to be treated as objects. Boxing a value type packages it inside an instance of the Object reference type. This allows the value type to be stored on the garbage collected heap. Unboxing extracts the value type from the object. In this example, the integer variable i is boxed and assigned to object o.