首页 > 代码库 > c#抽象类

c#抽象类

using System;
using System.Collections.Generic;
using System.Linq;技术分享

 

using System.Text;
 
namespace 抽象类
{
    public abstract class information//定义抽象
    {
        public string Code { get;set;}
        public string Name { get; set; }
        public abstract void Showinfo();
 
    }
    public class JHinfo : information
    {
        public override void Showinfo()
        {
            Console.WriteLine("进货信息:\n"+Code+""+Name);
        }
    
    }
    public class SHinfo : information
    {
        public override void Showinfo()
        {
            Console.WriteLine("销售信息:\n"+Code+""+Name);
        }
    }
}
 class Program
    {
        static void Main(string[] args)
        {
            JHinfo jh = new JHinfo();
            SHinfo sh = new SHinfo();
            jh.Code = "战神";
            jh.Name = "笔记本电脑";
            sh.Code = "荣耀100";
            sh.Name = "华为手机";
            jh.Showinfo();
            sh.Showinfo();
            Console.ReadKey();
        }
    }
}

 

c#抽象类