如何在智能感知中显示当前范围?

How to display current scope in intellisense?

是否可以在显示intellisense时只显示当前class的方法/对象(ctrl + space)?

我有这样的简单表格:

public partial class TestForm : Form
{
    public TestForm() { InitializeComponent(); }

    private string jobName = "x";

    public int JobId = 0;

    public void DoJob() { }

    private void TestForm_Loaded(object sender, EventArgs e)
    {
        /*
            When hiting ctrl+space show me only: 
                Dispose(bool)
                DoJob()
                InitializeComponent()
                TestForm()
                TestForm_Loaded(object, System.EventArgs)
                components
                JobId
                jobName
        */
    }
}

为此,您需要访问 class' 上下文。您可以在 C# 中使用 this 关键字来执行此操作,因此键入 this. 以获得所需的 IntelliSense。请注意,它还会显示继承的成员。

我通常用它来浏览当前的 class 如果我还不太了解它,但除非必要,否则我不会使用 this 关键字本身,所以我将其删除之后再来一次。