Sample C# programming

Here is a sample C# program

using System;

class Student
{
//Member data.
string name;
int id;

//Member functions.
Public void Accept()
{
Console.WtiteLine("Enter the name:\t");
name =Console.ReadLine();
Console.WriteLine("Enter the id of employee:\t");
id=Convert.ToInt32(Console.ReadLine());
}
public void Display()
{
Console.WriteLine("The name is :{0}",name);
Console.WriteLine("The id is :{0}",id);
}
}
// class used to intiate student class
class Executestudent
{
public static void Main(string[] arg)
{
Student st=new Student();
st.Accept();
st.Display();
}
}

0 Comments:

Post a Comment



Newer Post Older Post Home