如何禁用在类名前自动编写命名空间的选项。 [英] How do I disable the option for automatically writing the namespace before the class name.

查看:49
本文介绍了如何禁用在类名前自动编写命名空间的选项。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我想禁用它(这是一个gif,打开链接):

Hi. I wanna disable this (it's a gif, open the link):

https://i.gyazo.com/2472900210f4e15b5f830e4b033e9b70.mp4

https://i.gyazo.com/2472900210f4e15b5f830e4b033e9b70.mp4

I我正在使用Visual Studio 2015,它有时会发生,有时却不会发生。我找不到禁用此功能的选项。 

I'm using Visual Studio 2015 and it sometimes happens and sometimes doesn't. I can't find option for disabling this feature. 

推荐答案

该视频质量不佳所以我不确定我明白。我认为你有一个带有"程序"的CSharp_Practicinig命名空间。类和"Emp"类。目前尚不清楚你在问什么,因为在这个例子中你可以写:

The quality of that video is not good so I am not sure I understand. I think you have a CSharp_Practicinig namespace with a "Program" class and an "Emp" class. It is not clear what you are asking since in this example you could write:

Emp e = new Emp();

所以我必须猜测你想要问什么。我想您正在尝试询问成员在同一个类(这里是Program类)的情况,并且您必须提供类名以在其他地方引用该成员,如:

So I must guess at what you are trying to ask. I think you are trying to ask about the situation where a member is in the same class (here the Program class) and you must provide the class name to reference the member elsewhere, as in:

using System;

namespace csConsole
{
    class Program
    {
        int something = 22;

        static void Main(string[] args)
        {
            something = 33;     // error
        }
    }
}




这不起作用。请参阅"静态"?这表示可以在不指定类的实例的情况下调用Main方法。 Main方法必须是静态的,因为操作系统不知道如何创建C#类(运行
系统执行的程序可以用多种语言中的任何一种编写)。我们必须将方法或其他成员静态化还有许多其他原因。当我们这样做时,当静态方法需要在它自己的类中使用任何东西时,我们必须提供该类的实例。
除非另一个成员也是静态的,并且当它们都是静态的,那么在同一个类中我们不需要提供资格。所以在前面的例子中,如果"某事物"是也是静态的,然后我们可以说  " something"。


这篇关于如何禁用在类名前自动编写命名空间的选项。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆