我尝试编写一个日志文件并创建了一个包含两个文本框和一个按钮的桌面应用程序。我希望 int 变量在 txt 文件中以双引号样式显示。我试图在赋值过程中将 $"{textBox1.Text}\"" 转换为 int 但无济于事 - 得到格式异常错误。那么如何在 txt 文件中将 int 变量显示为双标记?
string username = $"\"{textBox1.Text}\"";
File.AppendAllText(@"C:\Users\Cavid\Desktop\LogFiles\" +DateTime.Now.ToString("dd.MM.yyyy") + ".txt", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " " +username+ " has typed as username \r\n");
int password = Convert.ToInt32($"\"{textBox1.Text}\"");
File.AppendAllText(@"C:\Users\Cavid\Desktop\LogFiles\"+DateTime.Now.ToString("dd.MM.yyyy") + ".txt", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " " +password+ " has typed as password\r\n");
幕布斯7119047
aluckdog
心有法竹
相关分类