0

我收到以下错误:

An explicit conversion exists. Are you missing a cast?

为什么是这样?

存在显式转换

private async void getEmotion_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            try
            {
                emotionResult = await emotionServiceClient.RecognizeAsync(imageStream.AsStream());
                if(emotionResult != null)
                {
                    Scores score = emotionResult[0].Scores; 
                }
            }
            catch
            {
                Output.Text = "Error returning the Emotion";
            }
        }
4

1 回答 1

0

请参考此处回答的类似问题:无法将类型“Microsoft.ProjectOxford.Common.Contract.EmotionScores[]”隐式转换为“Microsoft.ProjectOxford.Emotion.Contract.Scores[]”

Scores 和 EmotionScores 在名称方面是相同的对象,但不能自动转换。你可以说

EmotionScores scores = emotionResult[0].Scores;

或者干脆

var scores = emotionResult[0].Scores;
于 2017-03-18T21:00:11.730 回答