Escaping single quote in String.Format()

后端 未结 3 2069
醉酒成梦
醉酒成梦 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:31

    You could just use the HTML entity, if it's for HTML.

    -- Edit

    '
    

    -- Edit

    Just to make this post not wrong, as everyone else has noted, escaping works fine :)

    string s = t.ToString("MMM d \\'yy 'at' H:mmm");
    

    And that's the last time I don't test something based on who is posting :)

提交回复
热议问题