$语句修改成string.Format语句,代码怎么改呀

杨译733 2021-04-04 04:35:55
string sqlString =$"insert into Students(StudentName,Gender,Birthday,AttendanceNO,Stulmage,Age,Phone,StudentAddress)VALUES('{students.StudentName}','{students.Gender}','{students.Birthday}','{students.AttendanceNO}','{students.Stulmage}',{students.Age},'{students.Phone}','{students.StudentAddress}')";
...全文
201 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
兔子-顾问 2021-04-05
  • 打赏
  • 举报
回复
等效: string sqlString = string.Format("insert into Students(StudentName,Gender,Birthday,AttendanceNO,Stulmage,Age,Phone,StudentAddress)VALUES('{0}','{1}','{2}','{3}','{4}',{students.Age},'{students.Phone}','{5}')", students.StudentName, students.Gender, students.Birthday, students.AttendanceNO, students.Stulmage, students.Age, students.Phone, students.StudentAddress); 建议看看说明,$挺好用 https://www.cnblogs.com/hilolin/p/9123970.html

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧