Write a program in C# Sharp to declare a simple structure

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

Write a program in C# Sharp to declare a simple structure. 
Expected Output:

Declare a simple structure :
-------------------------------- 
The sum of x and y is 40 

الأجوبة

using System;
struct w3rStruct
{
    public int x;
    public int y;
}
class strucExer1
    {
    public static void Main()
        {
        Console.Write("\n\nDeclare a simple structure :\n");
        Console.Write("--------------------------------\n"); 	
        w3rStruct w3st = new w3rStruct();
        w3st.x = 15;
        w3st.y = 25;
        int sum = w3st.x + w3st.y;
        Console.WriteLine("The sum of x and y is {0}\n",sum);
        }
    }
هل كان المحتوى مفيد؟

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

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