How to provide custom string placeholder for string format

后端 未结 8 2220
借酒劲吻你
借酒劲吻你 2020-12-24 07:15

I have a string

string str =\"Enter {0} patient name\";

I am using string.format to format it.

String.Format(str, \"Hello\         


        
8条回答
  •  被撕碎了的回忆
    2020-12-24 07:24

    You are probably better off using Replace for the custom field and Format for the rest, like:

    string str = "Enter {0} {pat} name";
    String.Format(str.Replace("{pat}", "Patient"), "Hello");
    

提交回复
热议问题