Create a Person class with Name and Age; print both.
Ready — edit the code above and click Run.
using System;
class Person { public string Name { get; set; } public int Age { get; set; } }
class Program {
static void Main() {
var p = new Person { Name = "Ali", Age = 25 };
Console.WriteLine($"{p.Name} is {p.Age}");
}
}
Try solving on your own first, then reveal the official answer.
Auto-properties are standard C# OOP—encapsulation with get/set.