有什么办法可以从文本文件中获取多个变量

I have a console game with a class called Item, which stores 5 variables inside of it. I also have a List filled with Items called LootTables. I would like the player to be able to create their own items to add to the LootTables in a config.txt file. Is this possible?

    public class Item
    {
        public Item(string _itemName, int _itemPrice, string _description = "", int _specialInt = 0, string _specialAction = "null")
        {
            itemName = _itemName;
            itemPrice = _itemPrice;
            specialInt = _specialInt;
            specialAction = _specialAction;
            description = _description;
        }


    }

和主要游戏

                lootTables.Add(new Item("Rock", 1, "A large gray rock"));
                lootTables.Add(new Item("Mystery Potion", 7, "A potion. It is unknown what it does.", 0, "random-potion"));
                lootTables.Add(new Item("Large Health Potion", 15, "A Health Potion that restores 10 health", 10, "health"));

有任何想法吗?

(C#: Split string and assign result to multiple string variables, How to read an entire file to a string using C#? are what I am looking for, but I need to combine them for a large amount of variables)

评论