SharpConfig配置文件操作组件

联合创作 · 2023-09-28

SharpConfig 是 .NET 的 CFG/INI 配置文件操作组件。可以使用 SharpConfig 以文本或二进制格式读取,修改和保存配置文件和流。

该库与 .NET、.NET Core 和 Mono 框架完全兼容。

配置文件示例:

[General]
# a comment
SomeString = Hello World!
SomeInteger = 10 # an inline comment
SomeFloat = 20.05
ABoolean = true

C# 代码:

Configuration config = Configuration.LoadFromFile( "sample.cfg" );
Section section = config["General"];

string someString = section["SomeString"].Value;
int someInteger = section["SomeInteger"].GetValue<int>();
float someFloat = section["SomeFloat"].GetValue<float>();
浏览 4
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报