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);
        }
    }
}

 

上一篇:xml基础一


下一篇:2021.1.17——指针和结构体的初步认识