Wednesday 22 August 2012

inheritance | example | source code in C sharp

inheritance | example | source code in C sharp
using System;
using System.Collections.Generic;
using System.Text;

namespace inh_sing
{
public class person
{
public string phone,name,address;
public void getp()
{
Console.WriteLine("Enter name:");
name=Console.ReadLine();

Console.WriteLine("Enter address:");
address = Console.ReadLine();

Console.WriteLine("Enter phone:");
phone = Console.ReadLine(); 


}
}

public class stud:person
{
public string course;
public int roll;
public void gets()
{
Console.WriteLine("Enter rollno:");
roll = int.Parse (Console.ReadLine());
Console.WriteLine("Enter course:");
course = Console.ReadLine();
}

public void display()
{
Console.WriteLine("Roll No:-" + roll);
Console.WriteLine("Name:-" + name);
Console.WriteLine("Course:-" + course);
Console.WriteLine("Address:-" + address);
Console.WriteLine("Phone:-" + phone);
}
}


public static void Main(string[] args)
{
stud s1 = new stud();
s1.getp();
s1.gets();
s1.display();
Console.ReadLine();
}
}
}
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: