请也给我建议一下改一下。无法将类型'System.Collections.Generic.List‘隐式转换为System.Collections.Generic.IEnumerable。存在显式转换(是否缺少强制转换?)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyNamespace
{
class Program
{
static void Main(string[] args)
{
List<int> eventIDs = new List<int>() { 53,90,344,2223,2225,4497,5512};
MatchNumbers(eventIDs,2200,2300);
}
public static void MatchNumbers(IEnumerable<uint> eventsSet, int lowerBound, int upperBound)
{
if (upperBound < lowerBound)
throw new Exception("Lower bound cant be bigger");
List<int> itemSet = (List<int>)eventsSet;
for (int i = lowerBound; i <= upperBound; i++)
{
int result = itemSet.BinarySearch(i);
if (result >= 0)
Console.WriteLine("Found{0}", i);
}
}
}
}发布于 2011-03-09 12:27:48
也请给我提个改的建议..
执行以下任一操作:
IEnumerable<int>而不是IEnumerable<int>int表示32位整数的有符号范围,而uint表示32位整数的无符号范围。由于值范围的不同,您不能同时交换泛型类型int和uint的类。
发布于 2011-03-09 12:25:34
问题是你不能把uint转换成int。
发布于 2011-03-09 12:33:44
List<uint> itemSet = eventsSet.toList();https://stackoverflow.com/questions/5241279
复制相似问题