简体   繁体   中英

C# equivalent of Java Class.this

Question : What can be the C# equivalent of Java Class.this ?

Why : Suppose I've same class Form1 in both Java and C# . In Java we can write Form1.this , how this can be written in C# .

There is no equivalent, C# has no nested class support where it also tracks outer instances. If needed you pass a pointer yourself and store it in a field/property.

If all you want is the normal this to reference members in the same instance, simply use the this keyword. Or even better, don't -- it's implied.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM