1
0

some sec fixes

This commit is contained in:
Debug_pro
2026-02-12 01:22:45 +03:00
parent 43d7845cf1
commit 72d7aa9575
4 changed files with 13 additions and 4 deletions

View File

@@ -3,12 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
namespace Lab
{
internal class Parsers
{
public static bool TryParseDouble(string? s, out double val) => double.TryParse((s ?? "").Trim().Replace(",", "."), out val);
public static bool TryParseDouble(string? s, out double val) => double.TryParse((s ?? "").Trim().Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture, out val) && !double.IsNaN(val) && !double.IsInfinity(val);
public static bool TryParseInt(string? s, out int val) => int.TryParse((s ?? "").Trim(), out val);
public static bool TryParseDoubleArray(string? s, out double[] vals, out string err)
@@ -21,7 +22,7 @@ namespace Lab
return false;
}
string[] parts = s.Split(new[] { ' ', '\t', '\n', '\r', ',', ';' });
string[] parts = s.Split(new[] { ' ', '\t', '\n', '\r', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
List<double> list = new List<double>();