c# - WPF中Form对应的 "this"是什么?

标签 c# wpf

我们在表单应用程序中使用的“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/

相关文章:

c# - 如何垂直翻转位图图像

.net - 如何反转 BooleanToVisibilityConverter?

c# - 如何使用 ItemsSource 在 DataGridCell 模板中绑定(bind) TextBlock.Text

wpf - 全局按钮光标

c# - Application.Idle 事件每次触发

c# - 禁用 InstallFiles 的自动回滚

c# - 我如何调整生产者 Actor 的速度,以便它不会向消费者 Actor 传达太多消息

c# - LINQ导致无效的类型转换吗?

c# - 更新到 2.5.5.2700 后 RavenDB DateTime 错误

c# - 在 WPF/XAML 中显示本地时区的时间