Vb.Net convert StrDup to C#.net

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-11 10:56:06

问题


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.


回答1:


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

or

strKey = strKey.PadRight(intKeySize, chrKeyFill)



回答2:


strKey += strKey.PadRight(strKey.Length + (intKeySize - intLength), chrKeyFill)



回答3:


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');


来源:https://stackoverflow.com/questions/5902246/vb-net-convert-strdup-to-c-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!