public static BindableProperty<GameMode> CurrentGameMode = new BindableProperty<GameMode>()
{
Value = GameMode.None
};
报错,怎么处理?
老师,我又研究了一下你发的资料,自己也试了一遍,发现普通的泛型定义没有问题,很可能是BindableProperty.cs的问题,没有写的很好,报的错误是The type 'GameMode' cannot be used as type parameter 'T' in the generic type or method 'BindableProperty<T>'. There is no boxing conversion from 'GameMode' to 'System.IEquatable<GameMode>'.
BindableProperty.cs:
using System;
public class BindableProperty<T> where T : IEquatable<T>
{
private T mValue;
public T Value
{
get => mValue;
set
{
if (!mValue.Equals(value))
{
mValue = value;
OnValueChanged?.Invoke(value);
}
}
}
public Action<T> OnValueChanged;
}
麻烦老师看看怎么解决最好,谢谢老师了!