Write a program in C# Sharp to declares a structure with a property, a method, and a private field
- برمجة سي شارب
- برمجة
- 2021-05-31
- ahmadghneem
الأجوبة
using System;
struct newStruct
{
private int num;
public int n
{
get
{
return num;
}
set
{
if (value < 50)
num = value;
}
}
public void clsMethod()
{
Console.WriteLine("\nThe stored value is: {0}\n", num);
}
}
class strucExer6
{
public static void Main()
{
Console.Write("\n\nDeclares a structure with a property, a method, and a private field :\n");
Console.Write("----------------------------------------------------------------------\n");
newStruct myInstance = new newStruct();
myInstance.n = 15;
myInstance.clsMethod();
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال