Sara Abdullah
1
Q:

exercises with new keyword in c#

using System;
public struct newStruct
{
    public int m, n;
    public newStruct(int pt1, int pt2)
    {
        m = pt1;
        n = pt2;
    }
}
// Declare and initialize struct objects.
class strucExer8
{
    static void Main()
    {
	Console.Write("\n\nStruct initialization without using the new operator :\n");
	Console.Write("----------------------------------------------------------\n");

        newStruct myPoint;

        myPoint.m = 30;
        myPoint.n = 40;


        Console.Write("\nnewStruct : ");
        Console.WriteLine("m = {0}, n = {1}", myPoint.m, myPoint.n);

        Console.WriteLine("\nPress any key to exit.");
        Console.ReadKey();
    }
}

0

New to Communities?

Join the community