在另一种语言中,我使用了函数 SPACE(10)
,给我一个包含 10 个空格的字符串。我想将其转换为 C#.NET。
我使用了 string.Empty().PadLeft(10)
。
这是正确的吗?
最佳答案
只需使用:
new String(' ', 10);
这是 MSDN 文档:
String
Constructor (Char
,Int32
)Initializes a new instance of the
String
class to the value indicated by a specified Unicode character repeated a specified number of times.
关于c# - 如何获得包含定义数量的空格的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16185922/