C# txt文档 请求大神指点,急急急!在线等!

2024-11-08 12:01:33
推荐回答(1个)
回答(1):

			string value = File.ReadAllText(@"f:\test.txt");	//假设test.txt里只有一行1,2,3
string[] numberStrs = value.Split(',');
int thirdNumber = int.Parse(numberStrs[2]) + 7; //第三个数加上7
numberStrs[2] = thirdNumber.ToString();
File.WriteAllText(@"f:\test.txt", string.Join(",", numberStrs));