OOPs Pratice Program
OOPs Pratice Program
modifiers which refine the declaration of a class. Here is the list of all
supported modifiers in C#.
}
public class record :emp
{
new public static int salary = 50000;
static void Main(string[] args)
{
Console.WriteLine(emp.age + " " + emp.salary + " " + salary);
}
}
class Program
{
public static void Main()
{
BaseClass b;
b = new Derived2Class();
b.Print();
}
}
Q4>Create a C# program that requests three names of people from the user and stores
them in an array of objects of type Person. To do this, first create a Person class
that has a Name property of type string and override the ToString() method.
End the program by reading people and executing the ToString() method on the
screen.
Input
Juan
Sara
Carlos
Output
using System;
public class FirstClass
{
public static void Main(string[] args)
{
int total = 3;
Person[] persons = new Person[total];
Console.ReadLine();
}