【问题标题】:An explicit conversion exists. Are you missing a cast?存在显式转换。你缺演员吗?
【发布时间】:2017-08-08 18:30:08
【问题描述】:

我收到以下错误:

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";
            }
        }

【问题讨论】:

    标签: api microsoft-cognitive emotion


    【解决方案1】:

    请参考一个类似的问题,在这里回答:Cannot implicitly convert type 'Microsoft.ProjectOxford.Common.Contract.EmotionScores[]' to 'Microsoft.ProjectOxford.Emotion.Contract.Scores[]'

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

    EmotionScores scores = emotionResult[0].Scores;
    

    或者干脆

    var scores = emotionResult[0].Scores;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-10
      相关资源
      最近更新 更多