I am trying to wrap my DateTime's date format in single quotes
eg DateTime.Now().ToString("yyyy-MM-dd") output will be like "2017-03-30"
My question, Is there anyway of producing the result like "'2017-03-30'" (ie single quotes within the double quotes)?
Use string.Format , or on C#6+ string interpolation :
// String format
string.Format("'{0}'", DateTime.Now.ToString("yyyy-MM-dd"));
// Interpolation
$"'{DateTime.Now.ToString("yyyy-MM-dd")}'";
Result:
'2017-03-30'
尝试使用string.Format
:
string.Format("'{0:yyyy-MM-dd}'", DateTime.Now)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.