Record of a student in C#
using System;
public struct student
{
public int rollNo;
public string name;
public string branch;
};
public class structPint
{
student s=new student();
public void input()
{
Console.Write("Enter Roll No :");
s.rollNo=Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Name :");
s.name=Convert.ToString(Console.ReadLine());
Console.Write("Enter Branch:");
s.branch=Convert.ToString(Console.ReadLine());
}
public void display()
{
Console.WriteLine("Roll No is:"+s.rollNo);
Console.WriteLine("Name is:"+s.name);
Console.WriteLine("Branch is:"+s.branch);
}
}
public class ExecuteStruct
{
public static void Main(String[] args)
{
structPint sp=new structPint();
sp.input();
sp.display();
Console.ReadLine();
}
}
output
using System;
public struct student
{
public int rollNo;
public string name;
public string branch;
};
public class structPint
{
student s=new student();
public void input()
{
Console.Write("Enter Roll No :");
s.rollNo=Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Name :");
s.name=Convert.ToString(Console.ReadLine());
Console.Write("Enter Branch:");
s.branch=Convert.ToString(Console.ReadLine());
}
public void display()
{
Console.WriteLine("Roll No is:"+s.rollNo);
Console.WriteLine("Name is:"+s.name);
Console.WriteLine("Branch is:"+s.branch);
}
}
public class ExecuteStruct
{
public static void Main(String[] args)
{
structPint sp=new structPint();
sp.input();
sp.display();
Console.ReadLine();
}
}
output
No comments:
Post a Comment