????TryCatch????????????????
???????????? ???????[ 2013/3/15 11:05:09 ] ????????
?????????????????TryCatch??????????????????ж????????е???????????????????е???????????????????????д???Demo???????????????д?????????????????TryCatch????????????????????????????????????????????????
static void Main(string[] args)
{
int loopCount=100;
List<string> strList = new List<string>();
for (int i = 0; i < loopCount; i++) {
strList.Add("str" + i);
}
int intTemp = 0;
Stopwatch sw2 = new Stopwatch();
sw2.Start();
foreach (string str in strList)
{
Console.WriteLine("????TryCatch");
int.TryParse(str?? out intTemp);
}
sw2.Stop();
Stopwatch sw = new Stopwatch();
sw.Start();
foreach (string str in strList)
{
try
{
Console.WriteLine("????TryCatch");
intTemp = Convert.ToInt32(str);
}
catch (Exception ex)
{
//??????????
}
}
sw.Stop();
Console.WriteLine("???????" + loopCount + "????TryCatch?????" + sw2.ElapsedMilliseconds);
Console.WriteLine("???????" + loopCount + "????TryCatch?????" + sw.ElapsedMilliseconds);
Console.WriteLine("??????????" );
Console.ReadLine();
}
??????????????????????????????????????????????????????????TryCatch????loopCount?100????н?????£?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11