我们在表单应用程序中使用的“this”。它在WPF中对应什么?是主窗口吗?我正在使用一个围绕表单应用程序构建的库,并且有很多“this”,但我不知道如何在 WPF 中转换“this”
最佳答案
在 C# 中,this
始终是对其使用的类的当前实例的引用。
事实上,引用 MSDN 的话:
The this keyword refers to the current instance of the class.
The following are common uses of this:
To qualify members hidden by similar names
To pass an object as a parameter to other methods
To declare indexers
可以通过上面的链接找到示例。
使用 extension methods 时,此规则有一个异常(exception)。但是,其中 this
是要公开扩展方法的对象类型的修饰符。
关于c# - WPF中Form对应的 "this"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6439208/