我有YAML
文件,如下所示。
Main:
GPort: 1234
IPort: 3000
Prefix: "192.168.0"
我编写了以下函数来解析文件。
public static ProgramConfiguration LoadConfiguration(string config)
{
var deserializer = new Deserializer();
StringReader sr = new StringReader(config);
var result = deserializer.Deserialize<ProgramConfiguration>(sr);
ProgramConfiguration bc = new ProgramConfiguration();
return result;
}
其中
public class ProgramConfiguration
{
public string Prefix { get; set;}
public int GPort { get; set; }
public int IPort { get; set; }
}
LoadConfiguration函数抛出错误。
An unhandled exception of type 'YamlDotNet.Core.YamlException' occurred in YamlDotNet.dll
at
var result = deserializer.Deserialize<ProgramConfiguration>(sr);
我做错了什么?