c#中怎样向代码文件的某部分插入几行代码??

就是先把文件(.cs文件)内容按行读出,在某一行下面插入几行代码,可以在读取的过程中插入吗??

 可以的
string file = "x:\\你的cs文件.cs";
string[] lines = System.IO.ReadAllLines(file);
string[] 要添加的行 = { "//1", "//2", "//3" };
int 要添加的位置 = 4;
System.IO.WriteAllLines(file, lines.Take(要添加的位置));
System.IO.AppendAllLines(file, 要添加的行);
System.IO.AppendAllLines(file, lines.Skip(要添加的位置));