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

  • برمجة سي شارب
  • برمجة

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 

الأجوبة

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);
        }
    }
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...