0% found this document useful (0 votes)
13 views8 pages

37 - 38 - Structure in C# TAE1

The document discusses structures in C#, including their declaration, members like fields and methods, differences from classes like being value types instead of reference types, and important points about automatic deallocation and ease of copying values. Structures are presented as a tool for efficiently organizing simple data types.

Uploaded by

ms.satbhai9579
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views8 pages

37 - 38 - Structure in C# TAE1

The document discusses structures in C#, including their declaration, members like fields and methods, differences from classes like being value types instead of reference types, and important points about automatic deallocation and ease of copying values. Structures are presented as a tool for efficiently organizing simple data types.

Uploaded by

ms.satbhai9579
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

G.H.

Raisoni College Of Engineering and


Management, Wagholi, Pune

Department Of MCA
Sub – C#.Net

TOPIC - Structure in c#

Submitted By :
Mahesh Satbhai ( F.Y MCA - 37 )
Mangesh Kavhar ( F.Y MCA - 38 )
1. Introduction to C# Structure:

• A structure is a user-defined data type in C# that represents a


group of related data fields.

• It is similar to a class but is a value type rather than a reference


type.

• Unlike classes, structures are typically used for lightweight data


types that do not require inheritance or complex behavior.
2. Declaration & Syntax

• Declare a structure using the struct keyword followed by the


structure name.
• Example : struct Point
{
public int X;
public int Y;
}
3. Members of a Structure:

➢ Fields:
- Data members that store information
- Accessed using dot notation (‘structureInstance.field’).

➢ Methods:
- Functions that operate on the data within the structure.

➢ Properties:
- Accessors for getting and setting values.
- Enhance encapsulation & provide controlled access to
structure members.
4. Differences Between Structure and Class:

Category Structure Class

Data Type Value Type Reference type

Assignment Operation Copies the value Copies the reference

Parameterless Constructors Not Allowed Allowed

Inheritance Not supported Always supported


4. Important Points about Structures:

• Once the structures go out of scope, it gets automatically deallocated.

• Created much more easily and quickly than heap types.

• Using structure it become easy to copy the variable’s values onto stack.

• A struct is a value type, whereas a class is a reference type.


6. Conclusion:

• Structures are a valuable tool for organizing and representing simple data
types efficiently.

• Understand their limitations and use them appropriately based on your


application's requirements.
Thank You…!!

You might also like