How to Conditionally Format a String in .Net?

前端 未结 7 776
清酒与你
清酒与你 2020-12-16 09:50

I would like to do some condition formatting of strings. I know that you can do some conditional formatting of integers and floats as follows:

Int32 i = 0;
         


        
7条回答
  •  不思量自难忘°
    2020-12-16 10:35

    Just don't. I have no idea what are both the items and values in your code, but I believe, this pair could be treated as an entity of some kind. Define this entity as a class and override its ToString() method to return whatever you want. There's absolutely nothing wrong with having if for deciding how to format this string depending on some context.

提交回复
热议问题