Value types:
Value types are built in types such as integer and floating point numbers that are copied when they are passed as argument. Some of the value types are (int, float, double, byte).
using System; using System.Collections.Generic; using System.Linq; using System.Text; class program { public struct point { public int A, B; } static void main() { point p1 = new point(); p1.A = 21; point p2 = p1; Console.WriteLine(p1.A); Console.WriteLine(p2.A); p1.A = 50; Console.WriteLine(p1.A); Console.WriteLine(p2.A); } }
In the above code snippet we have declared two integers a, b using int data type, In the main method we created an object p1 for struct point, Finally we are calling the variable p1.A with that object. We also created the copy (p2) of object p1 we can use this object for different work around. Later we are changing the value of p1.A as 50.
output