[問題] 怎麼樣把int變數寫入文字檔?
我用了這個方法:
Random r1 = new Random(unchecked((int)DateTime.Now.Ticks));
int a = r1.Next(29) + 66;
string pathans = "\\My Documents\\mrwu\\Test\\ans.txt";
try
{
if (File.Exists(pathans))
{
File.Delete(pathans);
}
using (FileStream fs = File.Create(pathans))
{
錯誤>> Byte[] info = new UTF8Encoding(true).GetBytes(a.tostring);
fs.Write(info, 0, info.Length);
}
}
會再那一行出錯
1.最符合的多載方法 'System.Text.Encoding.GetBytes(char[])' 有一些無效的引數
2.無法從 '方法群組' 轉換為 'char[]'
請問該如何把int變數儲存在txt檔裡面呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.21.235.230
推
11/02 17:19, , 1F
11/02 17:19, 1F
→
11/02 17:24, , 2F
11/02 17:24, 2F
推
11/02 21:31, , 3F
11/02 21:31, 3F