diff --git a/Utils/Excel2Prompt.cs b/Utils/Excel2Prompt.cs index 3350b25..01d3608 100644 --- a/Utils/Excel2Prompt.cs +++ b/Utils/Excel2Prompt.cs @@ -80,39 +80,38 @@ public class Excel2Prompt { var str = item.ToString(); - // 检查是否为 Int + // 检查数据类型 if (!int.TryParse(str, out _)) + { isInt = false; - - // 检查是否为 Long + } if (!long.TryParse(str, out _)) + { isLong = false; - - // 检查是否为 Double + } if (!double.TryParse(str, out _)) + { isDouble = false; - - // 检查是否为 DateTime + } if (!DateTime.TryParse(str, out _)) + { isDateTime = false; - - // 检查是否为 Bool + } if (!bool.TryParse(str, out _)) + { isBool = false; + } } - if (isInt) - return "int"; - else if (isLong) - return "int64"; - else if (isDouble) - return "double"; - else if (isDateTime) - return "datetime"; - else if (isBool) - return "bool"; - else - return "string"; + return true switch + { + bool _ when isInt => "int", + bool _ when isLong => "int64", + bool _ when isDouble => "double", + bool _ when isDateTime => "datetime", + bool _ when isBool => "bool", + _ => "string", + }; } }