I have heard the following statement:
We can say class is a datatype or a datatype is one type of class.
Can anyone explain to me what exactly this means?
I have heard the following statement:
We can say class is a datatype or a datatype is one type of class.
Can anyone explain to me what exactly this means?
A class is just one of the data types available in C#:
Data Types:
NOTE: I may be missing a few in above list
Classes are Reference Types.
A Data Type is a value type if it holds the data within its own memory allocation.
Reference types are allocated on the heap, and memory management is handled by the garbage collector. Value types are allocated on the stack or inline and are deallocated when they go out of scope. In general, value types are cheaper to allocate and deallocate.
Like for example
In this the class
Person
is reference type andname
is value type i.e data type.In this the struct
Person
is value type and alsoname
is value type i.e both are data type.A data type is a value type if it holds the data within its own memory allocation. A reference type contains a pointer to another memory location that holds the data.
In reference to MSDN article on Classes and Structures and also MSDN article on Reference Type and Value Type
A class is a kind of data type. Other kinds of data types include pointer types and interfaces.
A data type can be described as being either:
** Class is a user define data type. **