請也建議我更改.. 不能將類型'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);
}
}
}
}
編譯器已經找到了你的錯誤。 – BoltClock 2011-03-09 04:26:36