Q:

Write a program in C# Sharp to declare a simple structure and use of static fields inside a structure

0

Write a program in C# Sharp to declare a simple structure and use of static fields inside a structure. 
Expected Output :

Structure with the use of static fields inside a structure :                            
---------------------------------------------------------                       
The sum of x and y is 40 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;

struct ahgStruct
{
public static int x = 15;
public static int y = 25;
}
class strucExer2
    {
    public static void Main()
        {
        Console.Write("\n\nStructure with the use of static fields inside a structure :\n");
        Console.Write("-------------------------------------------------------------\n"); 	
        int sum =ahgStruct.x + ahgStruct.y;
        Console.WriteLine("The sum of x and y is {0}\n",sum);
        }
    }

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now