C# Datatype:-
We can say three types of Datatype in C#: Value type,Reference type,pointer type
1.Value type uses stack,and have discrete values stores in it; It does not implement data hiding features;
2.Reference type:stored in heap , .Net framework support two reference types which are Object and String;Object is the base type for Value type and reference type;
They implement data hiding concept, and their data can be manipulated by using methods;
3.Pointer type: they are not type safe, they are not controlled by G.C. while reference type are in control of GC;
Arithematic operation can be performed on Pointer type while it is not possible on reference type;
------------------------------------------------------------------------
All variables (Value type and reference type) are the class variable first.
so they can be used as an object anywhere in the system;
------------------------------------------------------------------------
Nullable Types
C# supports nullable types. nullable is a struct which has two public members.
One is Hasvalue() which return true or false.and other one is value which returns the value only if HasValue() is true , else while accessing the value property it throw an exception;
They can be used as follows:-
System.Nullable
or
int? a=10; or int? a=null;
while We can not write int a=null;, this will give an error that a is not nullable type.
--> They can be used with Value type only not with reference type;
------------------------------------------------------------------------------
SOme Note POints:-
structure elements are protected by default while class members are private by default in C#;
Structure can contain constructor,destructor,methods,properties .
structure element can not be initialized by any given value in structure.while class variable initialized by default values.
C# Class always created in heap while structure can be created in Heap or stack.
----------
Datatype.MaxValue amd Datatype.MinValue can be used to determine the range of the datatype. while these thing can not be implemented in some Datatype like bool;
----------
------------------------------------------------------------------------------
Boxing:-
It is a concept of converting a value type into Reference type.
It is a expensive process, it uses some process cycle to do so
and data reside at two place and may have contradictory state at the same time.
------------------------------------------------------------------------------
C# Supports Jagged arrays(Different rows can have different number of column )
------------------------------------------------------------------------------
This is what i studied today.........
Feedback and comments are required to improve....................
Thanks & Regards
Bheeshma P. Nayak
3 comments:
Right..
Nullable types are really useful when your variable in code need to store data from database which can contain values(real number\string\etc) or null.
These type were introduced to accomodate these kind of functionality.
Yes Ketan, You have got the point..
Now i want you to refer var in .net3.5,which is a very intelligent Keyword.
It is something like varient in VB
AMHSEEHB
Yes.. var types. The annonymous types.It comes in very handy while dealing with list of objects(data structures) by creating a query in code by using lamda expression.
They are also capable to hold data without having any type or structure,hence name annonymous is coined.
Please deal with this type in your coming blog.It will be gud reference for us all.
Post a Comment