加 大括號是表示 滿足 小括號中條件時執行的。 而不加 大括號,則表示默認的滿足條件時,執行后面的第一句話。以分號結束。
if( ){
表達式1;
表達式2;
表達式3;
表達式4;
}
表達式1,2,3,4 都會執行的。
而不加
if()
表達式1;表達式2;
表達式3;
表達式 2,3 都不會執行的。因為不是后面第一句。
while ((line = sr.ReadLine()) != null) { //1.去掉空行 if (string.IsNullOrEmpty(line)) continue; //2.必須是A后面的行 if (line.Contains("A")) isA = true; //3.每行必須包含. 長度大於10個字符 if (isA && line.Contains(".") && line.Length > 10) list.Add(line); } //list實現數據后,設置完成天數, Console.WriteLine("輸入完成天數:"); var days = Console.ReadLine();//天數 int num = list.Count;//單詞數 if (int.Parse(days) >= 10 && int.Parse(days) <= 100) { int daysword = num / int.Parse(days);//每日背單詞數30 int number=0; for (int j = 0; j < int.Parse(days); j++)