string.Format() giving “Input string is not in correct format”

前端 未结 1 1122
孤街浪徒
孤街浪徒 2020-11-30 03:29

What do I do wrong here?

string tmp = @\"
    if (UseImageFiles) {
        vCalHeader += \"\"

        
相关标签:
1条回答
  • 2020-11-30 04:07

    string.Format() considers each '{' or '}' to be part of a placeholder (like '{0}' you already use). You need to escape each literal occurrence by doubling it.

    So in your case do:

     string tmp = @"
        if (UseImageFiles) {{
            ...
        }}";
    
    0 讨论(0)
提交回复
热议问题