基础入门必知必会,接口的定义和实现best基础入门程序的
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
//Console.WriteLine("Hello World!");
// 使用子类创建 接口 类的对象
Console.WriteLine("-----接口的定义和实现程序------");
Information info = new JhInfo();
info.Name = "手机";
info.Code = "001";
info.ShowInfo();
}
}
// 接口定义 0.1
interface Information
{
string Code { get; set; }
string Name { get; set; }
// 方法定义
void ShowInfo();
}
// 子类 派生类 0.2 子类定义 ,相当于业务场景中的业务类定义,或者手写,或者代码生成器生成
public class JhInfo:Information
{
string code = "";
string name = "";
// 属性定义 0.3 实现接口中的2个属性成员
public string Code
{



