INHERITANCE

Unknown | 5:42 AM |

Two types:-Single level & Multilevel
There is a class & a child class. A class can access the result from child class.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        class student
        {
            int rno;
            string name, address;
            public void getdata(int r, string n, string add)
            {
                rno = r;
                name = n;
                address = add;

            }
            public void display()
            {
                Console.WriteLine("ROLL NUMBER: "+rno.ToString());
                Console.WriteLine("Name: " + name);
                Console.WriteLine("Address: " + address);
            }
        }
        class accadamic : student
        {
            int rollno, mark1, mark2, total;
            public void getmarks(int r, int m1, int m2)
            {
                rollno = r;
                mark1 = m1;
                mark2 = m2;
            }
            public void result()
            {
                Console.WriteLine("Mark1: " + mark1.ToString());
                Console.WriteLine("Mark2: " + mark2.ToString());
                total = mark1 + mark2;
                Console.WriteLine("Total marks: " + total.ToString());

            }
        }
        static void Main(string[] args)
        {
            accadamic acd = new accadamic();
            Console.WriteLine("enter rollno,name,address");
            acd.getdata(Convert.ToInt16(Console.ReadLine()), Console.ReadLine(), Console.ReadLine());
            Console.WriteLine("enter marks");
            acd.getmarks(Convert.ToInt16(Console.ReadLine()),Convert.ToInt16(Console.ReadLine()),Convert.ToInt16(Console.ReadLine()));
            acd.display();
            acd.result();

            Console.WriteLine("end");
            Console.ReadLine();
        }
    }
}

Category:

About http://dotnetvisual.blogspot.in/:
DOT NET TO ASP.NET is a web application framework marketed by Microsoft that programmers can use to build dynamic web sites, web applications and web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime, allowing programmers to write ASP.NET code using any Microsoft .NET language. create an application very easily ....