我有以下字符串,取自VS2013中我的项目的资源:
.txt, Text Document
.exe, Application
.py, Python File
.jpg, Image File
.png, Image File
.dll, Application Extension
.js, Javascript File
.mp3, Music File
.mp4, Video File
.wmv, Video File
.ini, Configuration File
.sys, System File
.log, Log File
.rar, RAR Archive
.zip, Compressed folder
.bmp, Image File
.MSI, MSI File
.cab, cab File
.gitignore, Git Ignore File
.gitattributes, Git Attributes File
.csproj, C# Project File
.md, Markdown File
.sln, Visual Studio Solution File
我如何将其转换为字典?我想我会把它分成逗号和换行符,但是我在制定细节方面遇到了麻烦......
答案 0 :(得分:3)
str.Split(new [] { Environment.NewLine }, StringSplitOptions.None)
.ToDictionary(x => x.Split(',')[0], x => x.Split(',')[1]);