+ 10

What is the different between a struct and a class in c#?

10th Jun 2017, 8:14 AM
Gregor Duff
Gregor Duff - avatar
6 Antworten
+ 1
1. class has all the member private by default , but structure is a class where member are public by default . 2. classes allow to perform garbage collector before object is deallocated because g.c. work on heap memory !!
11th Jun 2017, 2:39 AM
deepanshu samdani
deepanshu samdani - avatar
+ 7
@Nanda Balakrishnan well thanks..
10th Jun 2017, 8:44 AM
Gregor Duff
Gregor Duff - avatar
+ 6
okk..thanks a lot..@deepanshu samdani
11th Jun 2017, 10:45 PM
Gregor Duff
Gregor Duff - avatar
+ 4
A structure is a value type so it is stored on the stack, but a class is a reference type and is stored on the heap. A structure doesn't support inheritance, and polymorphism, but aclass supports both. By default, all the struct members are public but classmembers are by default private in nature. http://www.careerride.com/C++-difference-between-struct-and-class.aspx refer this link which will help u
10th Jun 2017, 8:38 AM
Nanda Balakrishnan
+ 3
welcome
10th Jun 2017, 8:44 AM
Nanda Balakrishnan
+ 3
Class has data members private by default, with member functions or methods. Struct data members are public by default, also Struct have no methods.
28th Jul 2017, 9:34 PM
Rick Zalman