我想在文件中保存整数或双精度值??我已经通过这种方法放置了字符串

I want to save integer or double value in file ?? I have done to put string by this method

字符串示例="Example";

System.IO.File.WriteAllText(@"C:\WriteText.txt", 文本);

字符串输出=system.Io.file.Readalltext(@"C:/example.txt");

console.write("output"+输出);

使用System.IO; //访问 StreamWriter 和 StreamReader Class.

//将项目写入文件

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();