C# abstract class

An abstract class defines the base class definition that derived classes can have in common. You can declare methods in the abstract class and implement them later in the derived classes. You can not create an object from an abstract class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Csharpproject
{


   abstract class computer
   {
    
     void setName(string name){}
     void setIp(string ip){}
     void printInfo() { }
   }
   class Program:computer
   {
     static string cname;
     static string cip;
     static void Main(string[] args)
     {
        
        setName("PC1");
        setIp("192.168.100.2");
        printInfo();
        Console.Read();

     }
     static void setName(string name )
     {
        cname = name;
     }
     static void setIp(string ip)
     {
        cip = ip;
     }
     static void printInfo()
     {
        Console .WriteLine("Computer name:",cname);
        Console.WriteLine("Computer ip:", cip);

     }
}
}

Posted by: sello | post date: 01-25-2013 | Subject: C# Programming Language




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.