简体   繁体   中英

Vb.Net convert StrDup to C#.net

I have this line of code:

strKey &= Strings.StrDup(intKeySize - intLength, chrKeyFill)

What is the equivalent of this code in C#? I can't seem to find it.

strKey += new String(chrKeyFill, intKeySize - intLength);

或者

strKey = strKey.PadRight(intKeySize, chrKeyFill)

Personally I think the String constructor approach is clumsy and less readable than the VB.Net Strings library.

 using Microsoft.VisualBasic;
 ...
 Strings.StrDup(2, '\t');
strKey += strKey.PadRight(strKey.Length + (intKeySize - intLength), chrKeyFill)

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