Hi,
I’m attempting to attach a generic/abstract DataSeries to an INotifyPropertyChanged object. However, the TX, TY generics seem to block me from using it as expected. Can anyone help me out?
internal class DataSeriesAbstract : INotifyPropertyChanged
{
public string dataName;
public double lastAppendedTimestamp = 0.0f;
public List<AbstractChartViewModel> subscribers;
// gives an error that TX and TY cannot be found
public DataSeries<TX, TY> realData;
public DataSeries<TX, TY> Data
{
get { return realData; }
set
{
realData = value;
OnPropertyChanged(dataName);
}
}
...
}
Thank you
- Matt Carroll asked 6 years ago
- last edited 6 years ago
- You must login to post comments
Hi Jan
According to c# language spec, you have to do this:
// Specify the TX,Ty here making the class generic
internal class DataSeriesAbstract<TX,TY> : INotifyPropertyChanged where TX:IComparable where TY:IComparable
{
public string dataName;
public double lastAppendedTimestamp = 0.0f;
public List<AbstractChartViewModel> subscribers;
public DataSeries<TX, TY> realData;
public DataSeries<TX, TY> Data
{
get { return realData; }
set
{
realData = value;
OnPropertyChanged(dataName);
}
}
...
}
or this
internal class DataSeriesAbstract : INotifyPropertyChanged
{
public string dataName;
public double lastAppendedTimestamp = 0.0f;
public List<AbstractChartViewModel> subscribers;
// Specify the type here
public DataSeries<double, double> realData;
public DataSeries<double, double> Data
{
get { return realData; }
set
{
realData = value;
OnPropertyChanged(dataName);
}
}
...
}
Best regards,
Andrew
- Andrew Burnett-Thompson answered 6 years ago
- You must login to post comments
Please login first to submit.