如何使原始类(int)子类INotifyPropertyChanged
我如何将原始类型设置为 INotifyPropertyChanged 的子类 int
?我可以在不创建额外课程的情况下这样做吗?
How can i make a primitive type as int
a subclass of INotifyPropertyChanged? Can i do so without creating an additional class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
int
是一个不可变的结构,因此这一点没有实际意义。但不行,您不能将接口添加到不属于您的类或结构中。你必须以某种方式包裹它。
int
is an immutable struct so the point is moot.But no, you cannot add interfaces to a class or struct you don't own. You'd have to wrap it somehow.
最好的选择是创建自己的类来实现 INotifyPropertyChanged 并包装类型。
一个简单的例子是:
Your best bet is to make your own class that implements INotifyPropertyChanged and wraps the type.
A quick example would be: