📜  c# 将字符串数组转换为 int 数组 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:44.394000             🧑  作者: Mango

代码示例3
// Convert all the strings to integers
string[] stringIds = new string[] {"1", "2", "3"};
int[] ids = Array.ConvertAll(stringIds, s => {
  // The TryPrase() Method allows you to receive information
  // whether a element in the array was successfully converted
  bool success = int.TryParse(s, out int result);
  return result;
});