使用此关键字

use*_*439 2 .net c# this

我正在制作一个窗口表单应用程序.当我查看文件Form1.Designer.cs然后在我看到的自动生成的代码中

        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(284, 262);
        this.Controls.Add(this.button2);
        this.Controls.Add(this.button1);
        this.Name = "Form1";
        this.Text = "Form1";
        this.ResumeLayout(false);
Run Code Online (Sandbox Code Playgroud)

这是什么告诉那里,在多少方面,这可以在C#中使用

Dar*_*ren 6

它指的是该类的当前实例.如果您使用像ReSharper这样的工具,有时可能会被视为多余.

public class Test
{
        private string testVariable;

        public Test(string testVariable) 
        {
            this.testVariable = testVariable;
        }
}
Run Code Online (Sandbox Code Playgroud)

在此上下文中this.testVariable引用类中的私有字符串,而不是testVariable通过构造函数传入.

http://msdn.microsoft.com/en-gb/library/dk1507sz(v=vs.71).aspx