shoppinglist.cs

来自「XmlSerialization this is only an example」· CS 代码 · 共 36 行

CS
36
字号
using System.Xml.Serialization;
using System.Collections.Generic;

namespace XmlSerialization
{
    [XmlRoot("shoppingList")]
    public class ShoppingList
    {
        private List<ShoppingItem> shoppingItems;

        public ShoppingList()
        {
            shoppingItems = new List<ShoppingItem>();
        }

        [XmlElement("item")]
        public ShoppingItem[] Items
        {
            get
            {
                return shoppingItems.ToArray();
            }
            set
            {
                shoppingItems.Clear();
                shoppingItems.AddRange(value);
            }
        }

        public void AddItem(ShoppingItem item)
        {
            shoppingItems.Add(item);
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?