Qt解決繼承QWidget後設置樣式(QSS)無效的辦法
阿新 • • 發佈:2021-02-02
C#中string和StringBuilder的區別
string類
string a = "helloworld";
a.Insert(5, " ");
string b = a;
Console.WriteLine(a);
Console.WriteLine(b);
a = "keep on never give up.";
Console. WriteLine(a);
Console.WriteLine(b);
StringBuilder類
StringBuilder str1 = new StringBuilder("helloworld");
str1.Insert(5, " ");
StringBuilder str2 = str1;
Console.WriteLine(str1);
Console.WriteLine(str2);
str1 = new StringBuilder("keep on never give up");
str2 = str1;
Console.WriteLine(str1);
Console.WriteLine(str2);
string和StringBuilder執行時間上的區別
string str = "";
long stratTime = DateTime.Now.Millisecond;
for (int i = 0; i < 10000; i++)
{
str += i;
}
long endTime = DateTime.Now.Millisecond;
long time = endTime - stratTime;
Console.WriteLine(time);
StringBuilder str2 = new StringBuilder("");
stratTime = DateTime.Now.Millisecond;
for (int i = 0; i < 10000; i++)
{
str2.Append(i);
}
endTime = DateTime.Now.Millisecond;
time = endTime - stratTime;
Console.WriteLine(time);