1. What is structure?
A: The structure is a data type defined by a programmer. It is very similar to a class.
2. What are the differences between structures and classes?
1. The class is the reference type, and the structure is the value type.
2. structures are implicitly sealed, so they cannot be derived.
Iii. Structure declaration Syntax:
Struct StructName
{
Statement;
}
Note: 1. struct declares the structure keyword.
2. StructName is the structure name.
4. What is the structure declaration and instantiation call?
The Code is as follows:
Class Program
{
Static voidMain (string [] args)
{
Simple s1 = new Simple ();
Simple s2 = new Simple (5, 10 );
Console. WriteLine ("the value of letter creation using simplified method is: {0}, {1}", s1.x, s1.y );
Console. WriteLine ("the value of component build function is {0}, {1}", s2.x, s2.y );
Console. ReadKey ();
}
}
Struct Simple
{
Public int x;
Public int y;
Public Simple (int a, int B)
{
X =;
Y = B;
}
} Www.2cto.com
The program output result is:
0, 0
5, 10
The author's wheat forever.