C# - class and struct difference

Important differences between struct and class in C#
 - struct is value type but class is reference type (value and reference type description here)
 - struct does not support inheritance
 - struct does parameterless constructor generated by compiler and we can NOT overload such constructor (this constructor is used for assign default values to struct fields) while class can has many overloaded constructors

Just to compare In C++:
 - the only difference is that default modifier for struct is private while it is public for class

0 comments:

Post a Comment

Powered by Blogger.

Sample Text

Sample Text

Sample text

Sample Text

Social Icons

Social Icons

Followers

Featured Posts