我使用一個轉換到List<string>
轉換爲List<UInt32>
轉換出現FormatException處理
它確實很好,但是當數組元素之一不是可轉換,ToUint32扔FormatException
。
我想通知用戶有關失敗的元素。
try
{
List<UInt32> MyList = SomeStringList.ConvertAll(new Converter<string, UInt32>(element => Convert.ToUInt32(element)));
}
catch (FormatException ex)
{
//Want to display some message here regarding element.
}
我正在捕捉FormatException,但無法找到它是否包含字符串名稱。