码迷,mamicode.com
首页 > Windows程序 > 详细

C#命名空间

时间:2017-10-17 21:44:12      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:ring   static   定义   输出   console   ons   通过   关键字   class   

namespace again

namespace:命名空间关键字 again命名名称;

接下来看一下明明空间该如何使用:

定义两个明明空间,分别在里边定义一个方法

namespace one
{
    class first
    {
        public void eat()
        {
            Console.WriteLine("别光记得吃");
        }
    }
}

namespace two
{
    class twos
    {
        public void run()
        {
            Console.WriteLine("吃饱了记得散步");
        }
    }
}

        static void Main(string[] args)
        {

//通过命名空间下的类名调用方法;

            one.first f = new one.first();
            two.twos t = new two.twos();
            f.eat();
            t.run();

        }

最终输出语句:

别光记得吃

吃饱了记得散步

 

C#命名空间

标签:ring   static   定义   输出   console   ons   通过   关键字   class   

原文地址:http://www.cnblogs.com/qixiaolan/p/7683787.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!