tryParse, try/catch(Parse), Convert比较
private List<Int32> TestParse(String[] strings)
{
Int32 intValue;
List<Int32> intList = new List<int>();
for (int i = 0; i < 5000000; i++)
{
intList.Clear();
foreach (String str in strings)
{
try
{
intValue = Int32.Parse(str);
intList.Add(intValue);
}
catch (System.ArgumentException)
{ }
catch (System.FormatException)
{ }
catch (System.OverflowException)
{ }
}
}
return intList;
}
private List<Int32> TestTryParse(String[] strings)
{
Int32 intValue;
List<Int32> intList = new List<int>();
Boolean ret;
for (int i = 0; i < 5000000; i++)
{
intList.Clear();
foreach (String str in strings)
{
ret = Int32.TryParse(str, out intValue);
if (ret)
{
intList.Add(intValue);
}
}
}
return intList;
}
private List<Int32> TestConvert(String[] strings)
{
Int32 intValue;
List<Int32> intList = new List<int>();
for (int i =
补充:软件开发 , C# ,