简体   繁体   中英

C# equivalent of VB6 character placeholder

Is there a C# equivalent to the @ sign used in the VB6 format function?

VB6 (@ Character placeholder)
Display a character or a space. If the string has a character in the position where the @ appears in the format string, display it; otherwise, display a space in that position. Placeholders are filled from right to left unless there is an ! character in the format string.

I guess you mean left-justify or right-justify using string.Format() .

In c# it is:

string s = string.Format("{0,-10}", 42);
// s = "42        "

string s = string.Format("{0,10}", 42);
// s = "        42"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM