在PHP 中 的vsprintf(format,argarray)函数 。数组的元素会被插入主字符串的百分比 (%) 符号处。该函数是逐步执行的。在第一个 % 符号中,插入 arg1,在第二个 % 符号处,插入 arg2,依此类推。 在c# 中有没有 这样的函数????

解决方案 »

  1.   

    如果只是为数组内每个元素添加一个 %
    可以这样argarray=argarray.Select(a=>String.Formate("{0}%",a)).ToArray();
      

  2.   

    楼主说的是占位符
    C#中有 string.Format可以达到效果,这个方法有好多个版本的重载,下面只是其中一个,仅供参考。//
            // Summary:
            //     Replaces the format item in a specified string with the string representation
            //     of a corresponding object in a specified array.
            //
            // Parameters:
            //   format:
            //     A composite format string.
            //
            //   args:
            //     An object array that contains zero or more objects to format.
            //
            // Returns:
            //     A copy of format in which the format items have been replaced by the string
            //     representation of the corresponding objects in args.
            //
            // Exceptions:
            //   System.ArgumentNullException:
            //     format or args is null.
            //
            //   System.FormatException:
            //     format is invalid.-or- The index of a format item is less than zero, or greater
            //     than or equal to the length of the args array.
            public static string Format(string format, params object[] args);