<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                1、對話框 ``` using System; namespace Myapp { class Myclass { static void Main(string[] args) { Console.WriteLine("請輸入一個數字:"); string input = Console.ReadLine(); //用戶可以輸入 double d = double.Parse(input); //將用戶輸入的轉化成double類型 if ( d % 2 == 0) { Console.WriteLine("這是偶數");} else { Console.WrireLine("這是單數");} } } } ``` 2、屬性獲取 (c#(二)課時 5) 有 get+set 的就是屬性。 一般用get獲取屬性值,用set重置屬性值。 如下: ``` class Student { //姓名 string name; public string Name { get { return this.name;} set { this.name = value;} } //年齡 string age; public string Age { get { return this.age;} set { this.age = value;} } //地址 string address; public string Address { get { return this.address;} set { this.address = value;} } } ``` 第二種改法:屬性封裝 ``` class Student { //姓名 string name; public string Name { get { return this.name; } set { if ( value == "") { throw new ArgumentException("姓名字段不能為空"); this.name = value; } } } //年齡 int age; public int Age { get { return this.age; } set { if (value < 1 || value > 100) { throw new ArgumentException("年齡超出范圍"); this.age = value; } } } } ``` > 屬性也可以直接通過對象名后面加點 `.` 來調用或賦值 > `Student stu = new Student;` > `stu.Age = -2;` 如果屬性不需要特殊處理,可以直接 ` public string Name {get; set;}` 對于只讀屬性,只要在聲明時自動忽略就可以: `public string ProductNo{get;}`
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看