this
Allgemeines
Verweist auf die aktuelle Instanz der Klasse.
Beipiel
| C# |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
using System;
namespace GoloRoden.GuideToCSharp
{
/// <summary>
/// Represents a foo class.
/// </summary>
public class Foo
{
/// <summary>
/// Represents a bar method.
/// </summary>
public void Bar1()
{
// Call another method on this instance.
this.Bar2();
}
/// <summary>
/// Represents another bar method.
/// </summary>
public void Bar2()
{
}
}
}
|
Details
Ein statisches Element kann nicht auf this zugreifen, da das statische Element klassenbezogen
ist, this aber objektbezogen.
Siehe auch (Referenz)
Siehe auch (Guide)