C# 3.0 我想在文件中保存整数值或双数值??我已经用这个方法把字符串放好了

C# 3.0 我想在文件中保存整数值或双数值??我已经用这个方法把字符串放好了,c#-3.0,C# 3.0,字符串示例=示例 System.IO.File。WriteAllText@C:\WriteText.txt,文本 字符串输出=system.Io.file。Readalltext@C:/example.txt 控制台.writeoutput+输出 使用System.IO//访问StreamWriter和StreamReader类 //将项目写入文件的步骤 string myPath = @"C:/example.txt"; //this is where you put the text. St

字符串示例=示例

System.IO.File。WriteAllText@C:\WriteText.txt,文本

字符串输出=system.Io.file。Readalltext@C:/example.txt


控制台.writeoutput+输出

使用System.IO//访问StreamWriter和StreamReader类

//将项目写入文件的步骤

string myPath = @"C:/example.txt"; //this is where you put the text.
StreamWriter sw = new StreamWriter(myPath);
sw.Write("write something");
sw.Close();
//读取文件中的项目

string myPath = @"C:/example.txt"; //this is where you read the text.
StreamReader sr = new StreamReader(myPath);
string item = sr.ReadToEnd();
Console.WriteLine(item);
sr.Close();

您的问题是什么?如何通过控制台在文件中保存整数值或双数值??