【发布时间】:2011-09-10 09:02:35
【问题描述】:
谁能解释一下 C# 中“this”的含义?
如:
// complex.cs
using System;
public struct Complex
{
public int real;
public int imaginary;
public Complex(int real, int imaginary)
{
this.real = real;
this.imaginary = imaginary;
}
【问题讨论】:
-
何不抬头看看MSDN? "
this关键字是指类的当前实例。" -
见 MSDN:this (C# Reference)
-
vlad - 为什么不在 stackoverflow 上发帖?
-
@Vlad - 这个问题对许多针对 SO 提出的问题都有效。 SO的重点是成为一个可以作为参考的地方。首先,不是每个人都知道
MSDN(所以指出他们是个好主意)。其次,OP给出了上下文。有效问题 IMO。 -
搜索“this”这样的常用词非常困难。你真的去过 MSDN 网站并输入“this”来查看搜索结果吗?这和找出什么一样困难?和 ??在 if-then 语句中表示,或者在 lambda 表达式中表示 =>。
标签: c#