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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                **struct**關鍵字用于創建結構體 ~~~ struct Books { public string title; public string author; public string subject; public int book_id; }; ~~~ 類和結構的區別 * 類是引用類型,結構是值類型。 * 結構不支持繼承,也不能作為其他結構或類的基礎結構。 * 結構不能聲明默認的構造函數。 * 結構成員不能指定為 abstract、virtual 或 protected。 * 當您使用**New**操作符創建一個結構對象時,會調用適當的構造函數來創建結構。與類不同,結構可以不使用 New 操作符即可被實例化 * 如果不使用 New 操作符,只有在所有的字段都被初始化之后,字段才被賦值,對象才被使用。 * 結構可定義構造函數,但不能定義析構函數。但是,您不能為結構定義無參構造函數。無參構造函數(默認)是自動定義的,且不能被改變。 * 結構可帶有方法、字段、索引、屬性、運算符方法和事件。 * 結構可實現一個或多個接口。 **結構的用法:** ``` using System; using System.Text; ? ? ? struct Books { ? ?public string title; ? ?public string author; ? ?public string subject; ? ?public int book_id; }; ? public class testStructure { ? ?public static void Main(string[] args) ? ?{ ? ? ? Books Book1; ? ? ? ?/* 聲明 Book1,類型為 Books */ ? ? ? Books Book2; ? ? ? ?/* 聲明 Book2,類型為 Books */ ? ? ? /* book 1 詳述 */ ? ? ? Book1.title = "C Programming"; ? ? ? Book1.author = "Nuha Ali"; ? ? ? Book1.subject = "C Programming Tutorial"; ? ? ? Book1.book_id = 6495407; ? ? ? /* book 2 詳述 */ ? ? ? Book2.title = "Telecom Billing"; ? ? ? Book2.author = "Zara Ali"; ? ? ? Book2.subject = ?"Telecom Billing Tutorial"; ? ? ? Book2.book_id = 6495700; ? ? ? /* 打印 Book1 信息 */ ? ? ? Console.WriteLine( "Book 1 title : {0}", Book1.title); ? ? ? Console.WriteLine("Book 1 author : {0}", Book1.author); ? ? ? Console.WriteLine("Book 1 subject : {0}", Book1.subject); ? ? ? Console.WriteLine("Book 1 book_id :{0}", Book1.book_id); ? ? ? /* 打印 Book2 信息 */ ? ? ? Console.WriteLine("Book 2 title : {0}", Book2.title); ? ? ? Console.WriteLine("Book 2 author : {0}", Book2.author); ? ? ? Console.WriteLine("Book 2 subject : {0}", Book2.subject); ? ? ? Console.WriteLine("Book 2 book_id : {0}", Book2.book_id); ? ? ? ? ? ? Console.ReadKey(); ? ?} } ``` ``` using System; using System.Text; ? ? ? struct Books { ? ?private string title; ? ?private string author; ? ?private string subject; ? ?private int book_id; ? ?public void setValues(string t, string a, string s, int id) ? ?{ ? ? ? title = t; ? ? ? author = a; ? ? ? subject = s; ? ? ? book_id =id; ? ?} ? ?public void display() ? ?{ ? ? ? Console.WriteLine("Title : {0}", title); ? ? ? Console.WriteLine("Author : {0}", author); ? ? ? Console.WriteLine("Subject : {0}", subject); ? ? ? Console.WriteLine("Book_id :{0}", book_id); ? ?} }; ? public class testStructure { ? ?public static void Main(string[] args) ? ?{ ? ? ? Books Book1 = new Books(); /* 聲明 Book1,類型為 Books */ ? ? ? Books Book2 = new Books(); /* 聲明 Book2,類型為 Books */ ? ? ? /* book 1 詳述 */ ? ? ? Book1.setValues("C Programming", ? ? ? "Nuha Ali", "C Programming Tutorial",6495407); ? ? ? /* book 2 詳述 */ ? ? ? Book2.setValues("Telecom Billing", ? ? ? "Zara Ali", "Telecom Billing Tutorial", 6495700); ? ? ? /* 打印 Book1 信息 */ ? ? ? Book1.display(); ? ? ? /* 打印 Book2 信息 */ ? ? ? Book2.display(); ? ? ? Console.ReadKey(); ? ?} } ```
                  <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>

                              哎呀哎呀视频在线观看