Escaping single quote in String.Format()

后端 未结 3 2075
醉酒成梦
醉酒成梦 2020-12-15 04:10

I have been all over the \'tubes and I can\'t figure this one out. Might be simple.

The following String.Format call:

return dt.ToString         


        
3条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 04:38

    You can escape it using a backslash which you will have to escape. Either

    return dt.ToString(@"MMM d \'yy 'at' H:mmm");
    

    or

    return dt.ToString("MMM d \\'yy 'at' H:mmm");
    

提交回复
热议问题