View Single Post
  #1  
Old 17-06-2011, 09:50 PM
thecool's Avatar
thecool thecool is offline
Senior Member


 
Join Date: Apr 2009
Location: Multan
Posts: 1,163
Contact Number: Push me a PM if you really need
Program / Discipline: Alumni
Class Roll Number: ---
thecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond repute
Exclamation inheritance | example | source code in C sharp

inheritance | example | source code in C sharp

Code:
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();
}
}
}

Reply With Quote