标题:关于静态和非静态的最基础问题
只看楼主
梦想骑士
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-7-24
结帖率:100%
 问题点数:0 回复次数:0 
关于静态和非静态的最基础问题

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的函数的区别
搜索更多相关主题的帖子: abstract public 
2014-07-28 23:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-434501-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.049022 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved