解决警告问题

This commit is contained in:
zs-yg
2025-11-23 09:50:39 +08:00
parent 060edfb873
commit 8c5d3a8219

View File

@@ -51,14 +51,18 @@ namespace MCSJ.Tools.ServerManagement
// 解析JRE配置 // 解析JRE配置
var jreVersions = new Dictionary<string, Dictionary<string, string>>(); var jreVersions = new Dictionary<string, Dictionary<string, string>>();
string currentVersion = null; string currentVersion = string.Empty;
foreach (var line in File.ReadAllLines(jreConfigPath)) foreach (var line in File.ReadAllLines(jreConfigPath))
{ {
if (line.StartsWith("[") && line.EndsWith("]")) if (line.StartsWith("[") && line.EndsWith("]"))
{ {
currentVersion = line.Trim('[', ']'); var version = line.Trim('[', ']');
jreVersions[currentVersion] = new Dictionary<string, string>(); currentVersion = version ?? string.Empty;
if (currentVersion != null!)
{
jreVersions[currentVersion] = new Dictionary<string, string>();
}
} }
else if (line.Contains("=") && currentVersion != null) else if (line.Contains("=") && currentVersion != null)
{ {