求助帖,新手遇到了难题
net吧
全部回复
仅看楼主
level 3
马儿坡 楼主
急急急,在线等,
2015年10月16日 04点10分 1
level 3
马儿坡 楼主
我现在处于学习C#的开始阶段,结果师兄在知乎上面看到一道题,然后就叫我做,还发了一段代码给我,让我看懂就行,可是三天过去了,不但没看懂,还严重打击了学习热情,本来计划好了的学习计划都打乱了,秋大神帮助啊,
这里是知乎的题
http://www.zhihu.com/question/35889602
下面是师兄给的代码,
using System;
using System.IO;
using System.Linq;
class Program
{
static void Main(string[] args)
{
foreach (var item in File.ReadAllText(@"新建文本文档.txt").Split(new String[] { "\r\n\r\n\r\n" }, StringSplitOptions.RemoveEmptyEntries))
{
var title = String.Join("", item.Split(new String[] { " ", "\r\n" }, StringSplitOptions.RemoveEmptyEntries).First().Split(new String[] { " " }, StringSplitOptions.RemoveEmptyEntries));
var passage = " " + String.Join("", String.Join(title, (item + " ").Split(new String[] { title }, StringSplitOptions.RemoveEmptyEntries).Skip(1)).SkipWhile(x => x == ' ').Select(x => x.ToString()));
File.WriteAllText(@"新建文件夹\" + title + ".txt", passage.Substring(0, passage.Length - 1));
Console.WriteLine("《{0}》已分离。", title);
}
Console.WriteLine("分割结束,按任意键退出。");
Console.ReadKey();
}
}
求大神进来看看,指导一下小弟嘛,要是明天还看不懂就死定了。。
2015年10月16日 04点10分 2
1