Each .NET Framework language provides keywords that enable you to define two kinds of
User-defined value types: structures and enumerations.
When you create an instance of a value type, the memory is allocated in-place. For example, if you create a value-type object as a local variable in a method, the memory is allocated on the stack and is automatically released at the end of the enclosing scope. Conversely, if you declare a value-type object in a class, the memory is allocated as part of the memory block for the class object and is deallocated when the class object is garbage collected.
Defining Structure Types:
A structure is a user-defined value type that inherits directly from the System.ValueType type. You typically define structure types to represent numeric data types that you want to allocate and deallocate frequently such as currency values, coordinates, or dimensions. To define a structure type, use the struct (C#) keyword. A structure type can contain variables, methods, properties, and parameterized constructors. Structures can implement any number of interfaces, but they cannot explicitly inherit
From a class or be used as a base class.
The following examples show:
public int x1;
public Mystr(int x)
x1 = x;
public void show()
static void Main(string args)
Mystr s= new Mystr();
s.x1 = 123;
Output is display bellow.