Friday, March 9, 2018

Tutorial 15 What are Structs in C Sharp?

Structs and Classes Difference :


Structs are similar to classes in definition and syntax. Lets see the example of structs :


What is the difference :

Struct is a value type and class is a reference type.

Structs cant have destructors.

Structs cant support inheritance.

Structs are stored on Stack and class are stored in Heap.

What is sealed Keyword mean?

We use sealed keyword to stop a class being used in inheritance purpose and structs are by default sealed.

Syntax :

class sealed ClassVariablename



No comments:

Post a Comment