Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我被困住了。我在哪里可以在这个 C# 语句中添加“Trim”?每行将是一个单独的文件名。但是因为每个文件后面可能都有空格,所以我想把它剪掉。
string[] lines = (File.ReadAllLines(@"C:\Users\Jim\Desktop\adminkeys.cfg"));
谢谢
如果您尝试修剪每一行,那么您需要逐行进行,例如,使用 LINQ:
string[] lines = (File.ReadAllLines(@"C:\Users\Jim\Desktop\adminkeys.cfg")) .Select(l => l.Trim()).ToArray();