编程语言
首页 > 编程语言> > C# - Struct(结构体)

C# - Struct(结构体)

作者:互联网

注意:

内部变量必须声明为public,否则实例无法读写

using System;

namespace day0908._0906
{
    class demo4
    {
        struct Book {
            public string author;
            public string title;
            public double price;
        }
        static public void Main()
        {
            Book book1;
            book1.author = "Piero Scaruffi";
            book1.title = "《Human2.0》";
            book1.price = 68.00;
            Console.WriteLine("{0}\n{1}\n{2}\n",book1.title,book1.author,book1.price);
        }
    }
}

 

标签:Struct,author,C#,price,title,book1,Book,public,结构
来源: https://blog.csdn.net/qq_42292831/article/details/100585728