Can maximum number of characters be defined in C# format strings like in C printf?

后端 未结 6 627
失恋的感觉
失恋的感觉 2020-12-10 01:42

Didn\'t find how to do that. What I found was more or less on the lines of this (http://blog.stevex.net/string-formatting-in-csharp/):

There really isn’t any formatt

6条回答
  •  爱一瞬间的悲伤
    2020-12-10 01:48

    Why not just use Substr to limit the length of your string?

    String s = "abcdefghijklmnopqrstuvwxyz";
    String.Format("Character limited: {0}", s.Substr(0, 10));
    

提交回复
热议问题