突然要用到把一個String重復N遍不是循環的方法
CSDN上找了下
public static string RepeatString(string str
{
char[] arr = str
char[] arrDest = new char[arr
for (int i =
{
Buffer
}
return new string(arrDest);
}
感覺是內存分配上面效率高吧
把這個方法改成泛型會不會就沒效率了呢?
public static string RepeatString(T str
{
string s = str
char[] arr = s
char[] arrDest = new char[arr
for (int i =
{
Buffer
}
return new string(arrDest);
}
}
posted on
From:http://tw.wingwit.com/Article/program/net/201311/15396.html