Answers for "exercises with new keyword in c#"

C#
0

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();
    }
}
Posted by: Guest on October-08-2020

C# Answers by Framework

Browse Popular Code Answers by Language