1. 程式人生 > 其它 >Qt解決繼承QWidget後設置樣式(QSS)無效的辦法

Qt解決繼承QWidget後設置樣式(QSS)無效的辦法

技術標籤:c#入門c#

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

在這裡插入圖片描述