diff --git a/DisplayUtil/Template/UtilTemplateExtender.cs b/DisplayUtil/Template/UtilTemplateExtender.cs index a665bb5..2eb2559 100644 --- a/DisplayUtil/Template/UtilTemplateExtender.cs +++ b/DisplayUtil/Template/UtilTemplateExtender.cs @@ -18,7 +18,11 @@ public void Enrich(ScriptObject scriptObject, EnrichScope scope) public static float ToFloat(string? content) { if (content == null) return 0; - return float.Parse(content, CultureInfo.InvariantCulture); + if (float.TryParse(content, CultureInfo.InvariantCulture, out var value)) + { + return value; + } + return 0; } public static string TimespanToString(TimeSpan timeSpan, string format)