Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

difference between class and struct

Class: 
1. Members of a class are private by default.
2. Base classes/structures of a class are private by default.
3. It is declared using the class keyword.
4. It support inheritance.
5. It is refference type
6. It can have NULL values
7.It may have all the types of constructors and destructors.

Structure:
1. Members of a structure are public by default. 
2. Base classes/structures of a structure are public by default.
3. It is declared using the struct keyword.
4. It does not support inheritance.
5. It is value type.
6. It cannot have NULL values.
7. It may have only parameterized constructor.
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #difference #class #struct
ADD COMMENT
Topic
Name
9+2 =