【问题标题】:Vb.Net convert StrDup to C#.netVb.Net 将 StrDup 转换为 C#.net
【发布时间】:2011-08-19 14:57:42
【问题描述】:

我有这行代码:

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

这段代码在 C# 中的等价物是什么?好像没找到。

【问题讨论】:

    标签: c# vb.net strdup


    【解决方案1】:
    strKey += new String(chrKeyFill, intKeySize - intLength);
    

    strKey = strKey.PadRight(intKeySize, chrKeyFill)
    

    【讨论】:

      【解决方案2】:
      strKey += strKey.PadRight(strKey.Length + (intKeySize - intLength), chrKeyFill)
      

      【讨论】:

        【解决方案3】:

        我个人认为 String 构造方法比 VB.Net Strings 库笨拙且可读性差。

         using Microsoft.VisualBasic;
         ...
         Strings.StrDup(2, '\t');
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-03-03
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多