关于静态和非静态的最基础问题
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
public abstract class MX {
public void Methood() { }
public abstract void Methood1();
public abstract void Methood2();
public abstract void Methood3();
}
class LJP : MX
{
public override void Methood1()
{
Console.WriteLine("子类1的函数方法1");
}
public override void Methood2()
{
Console.WriteLine("子类1的函数方法2");
}
public override void Methood3()
{
Console.WriteLine("子类1的函数方法3");
}
}
class GQ : MX
{
public override void Methood1()
{
Console.WriteLine("子类2的函数方法3");
}
public override void Methood2()
{
Console.WriteLine("子类2的函数方法2");
}
public override void Methood3()
{
Console.WriteLine("子类2的函数方法3");
}
}
class GJX : MX
{
public override void Methood1()
{
Console.WriteLine("子类3的函数方法1");
}
public override void Methood2()
{
Console.WriteLine("子类3的函数方法2");
}
public override void Methood3()
{
Console.WriteLine("子类3的函数方法3");
}
}
class Program
{
public static void Methood(MX gq) {
gq.Methood1();
gq.Methood2();
gq.Methood3();
}
public static MX Methood(string name) {
if (name=="1")
{
return new LJP();
}
else if (name == "2")
{
return new GQ();
}
else {
return null;
}
}
static void Main(string[] args)
{
MX gjx = Methood("1");
if (gjx!=null)
{
gjx.Methood1();
gjx.Methood2();
gjx.Methood3();
}
}
}
}
1:public static MX Methood(string name) 2:public static MX Methood(string name)
一直对没有void或者是有 void没有statuc的函数的区别