【編程】C#使用總結



1. c#中計算時間方法:

// example2: Stopwatch class
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
System.Threading.Thread.Sleep(time_cap);
sw.Stop();

TimeSpan ts2 = sw.Elapsed;
Console.WriteLine("example2 time {0}", ts2.TotalMilliseconds);

 

2. 讀取date.csv中的數據至List<string> STRS.

List<string> STRS = new List<string>();
            StreamReader sr = new StreamReader("date.csv", Encoding.Default);
            String line;
            while ((line = sr.ReadLine()) != null)
            {
                //Console.WriteLine(line.ToString());
                STRS.Add(line.ToString());
            }
            return STRS;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章