Alternatives to “ ” for creating strings containing multiple whitespace characters

后端 未结 12 1420
粉色の甜心
粉色の甜心 2020-12-09 15:30

I\'m wondering if there\'s a more OO way of creating spaces in C#.

Literally Space Code!

I currently have tabs += new String(\" \"); and I can\'

12条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 16:26

    You may create class extensions.

    public static class StringExtensions
        {
            public static string GetSpace(this String)
            {
               return " ";
            }
        }
    

    and you can call this.

    String.GetSPace();
    

提交回复
热议问题