Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# equivalent of Java Class.this

Tags:

java

c#

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#.

like image 693
Protect Life Save Forests Avatar asked Dec 31 '25 21:12

Protect Life Save Forests


1 Answers

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.

like image 186
Blindy Avatar answered Jan 03 '26 10:01

Blindy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!