Cannot implicitly convert type 'Microsoft.Proj

2019-09-14 05:34发布

问题:

I am trying to run the sample app. It worked once and after that one time I keep getting the error in the title in the following code line in MainWindow.xaml.cs

EmotionScores = emotions.Select(e => e.Scores).ToArray()

What can I do ? Thanks

回答1:

The error message you get is pretty self-explanatory. You try to assign a reference to an array of Scores to a variable that can holds a reference to an array of EmotionScores. This cannot be done, because as it seems there isn't any implicit conversion between these types.

If just want to get and save somewhere the scores, you could just store them in another variable:

var scores = emotions.Select(e => e.Scores).ToArray();