2012-11-01 50 views
2

我hahe这个代码段:无法隐式转换类型 '诠释[]' 到“廉政[]

private FoundContours SelectFromFoundSamples(FoundContours foundACContours, FoundContours foundFNContours, FoundContours foundBlurContours, FoundContours foundFilteredContours) 
    { 

     int? num = null; 

     int? a = null, b = null, c = null, d = 10; 


     int?[] numbers = new[] { foundACContours.Count, foundFNContours.Count, foundBlurContours.Count, foundFilteredContours.Count }; 

     int? max = numbers.Max(); 
    } 

该行:

int?[] numbers = new[] { foundACContours.Count, foundFNContours.Count, foundBlurContours.Count, foundFilteredContours.Count }; 

我得到这个错误:

“无法隐式转换类型 '诠释?[]' 到 'INT []'

任何想法,我怎样才能修复这个错误?

预先感谢您。

+1

假设你'Count'成员'int',我得到的错误,即周围其他方式'...类型'int []'to'int?[]'' – Rawling

+0

我也明白,Rawling。另外,'num'和那四个'a','b','c'和'd'变量在做什么?使用可为空的整数而不是常规整数的原因是什么? – Heki

回答

7

只要改变你的声明

int?[] numbers = new[] { foundACContours.Count, foundFNContours.Count, 
         foundBlurContours.Count, foundFilteredContours.Count }; 

int?[] numbers = new int?[] { foundACContours.Count, foundFNContours.Count, 
          foundBlurContours.Count, foundFilteredContours.Count }; 
3
int?[] numbers = new int?[] { foundACContours.Count, foundFNContours.Count, foundBlurContours.Count, foundFilteredContours.Count }; 
相关问题