none
List of Objects RRS feed

  • Question

  • Trying to figure out the best way to build a list of objects. I think I have made a mistake somewhere in my logic. I have a base class for my objects and the class its self containing the objects. 

    base rune class:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace WBG_Crafting_Core
    {
        public class Base_Rune
        {
            /// <summary>
            /// Displayed Name
            /// </summary>
            public string Name { get; set; }
            /// <summary>
            /// Item Count
            /// </summary>
            public long Count { get; set; }
            /// <summary>
            /// Attributes added to socketed items
            /// </summary>
            public List<string>attributes { get; set; }
            /// <summary>
            /// NPC Cost Displayed In NPC Shop
            /// </summary>
            public long NPC_Sale { get; set; }
            /// <summary>
            /// Amount NPC Will give to player for item
            /// </summary>
            public long NPC_Buy { get; set; }
            /// <summary>
            /// WBG Store Cost
            /// </summary>
            public long WBG_Sale { get; set; }
        }
    }
    

    Rune class:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace WBG_Crafting_Core
    {
        public class WBG_Runes : Base_Rune
        {
            public string Ancient_Stone { get; set; }
            public string Polished_Ancient_Stone { get; set; }
            public string Rune_a { get; set; }
            public string Rune_da { get; set; }
            public string Rune_ja { get; set; }
            public string Rune_ka { get; set; }
            public string Rune_ma { get; set; }
            public string Rune_na { get; set; }
            public string Rune_pa { get; set; }
            public string Rune_ra { get; set; }
            public string Rune_sa { get; set; }
            public string Rune_ta { get; set; }
            public string Rune_wa { get; set; }
            public string Rune_za { get; set; }
            public string Rune_e { get; set; }
            public string Rune_de { get; set; }
            public string Rune_je { get; set; }
            public string Rune_ke { get; set; }
            public string Rune_me { get; set; }
            public string Rune_ne { get; set; }
            public string Rune_pe { get; set; }
            public string Rune_qe { get; set; }
            public string Rune_re { get; set; }
            public string Rune_se { get; set; }
            public string Rune_te { get; set; }
            public string Rune_we { get; set; }
            public string Rune_ze { get; set; }
            public string Rune_i { get; set; }
            public string Rune_di { get; set; }
            public string Rune_ki { get; set; }
            public string Rune_mi { get; set; }
            public string Rune_ni { get; set; }
            public string Rune_pi { get; set; }
            public string Rune_qi { get; set; }
            public string Rune_ri { get; set; }
            public string Rune_si { get; set; }
            public string Rune_ti { get; set; }
            public string Rune_wi { get; set; }
            public string Rune_o { get; set; }
            public string Rune_do { get; set; }
            public string Rune_jo { get; set; }
            public string Rune_ko { get; set; }
            public string Rune_mo { get; set; }
            public string Rune_no { get; set; }
            public string Rune_po { get; set; }
            public string Rune_qo { get; set; }
            public string Rune_ro { get; set; }
            public string Rune_so { get; set; }
            public string Rune_to { get; set; }
            public string Rune_wo { get; set; }
            public string Rune_zo { get; set; }
            public string Rune_u { get; set; }
            public string Rune_du { get; set; }
            public string Rune_ku { get; set; }
            public string Rune_mu { get; set; }
            public string Rune_nu { get; set; }
            public string Rune_pu { get; set; }
            public string Rune_ru { get; set; }
            public string Rune_su { get; set; }
            public string Rune_tu { get; set; }
            public string Rune_zu { get; set; }
    
            public List<WBG_Runes> Get_WBG_Runes()
            {
                List<WBG_Runes> Runes = new List<WBG_Runes>();
    
                foreach(var Rune in Runes)
                {
                    string rune = Rune.ToString();
    
                    switch (rune)
                    {
                        case "Ancient_Stone":
                            Rune.Name = "Ancient Stone";
                            Rune.NPC_Sale = 15;
                            Rune.NPC_Buy = 1;
                            Rune.WBG_Sale = 20;
                            Rune.Count = 0;
                            break;
                        case "Polished_Ancient_Stone ":
                            Rune.Name = "Polished Ancient Stone";
                            Rune.NPC_Sale = 25;
                            Rune.NPC_Buy = 3;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_a":
                            Rune.Name = rune.Replace("Rune_","");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_da ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ja ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ka ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ma ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_na ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_pa ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ra ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_sa ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ta ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_wa ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_za ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_e ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_de ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_je ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ke ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_me ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ne ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_pe ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_qe ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_re ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_se ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_te ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_we ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ze ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_i ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_di ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ki ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_mi ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ni ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_pi ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_qi ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ri ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_si ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ti ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_wi ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_o ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_do ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_jo ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ko ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_mo ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_no ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_po ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_qo ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ro ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_so ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_to ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_wo ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_zo ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_u ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_du ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ku ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_mu ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_nu ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_pu ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_ru ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_su ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_tu ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                        case "Rune_zu ":
                            Rune.Name = rune.Replace("Rune_", "");
                            Rune.NPC_Sale = 30;
                            Rune.NPC_Buy = 5;
                            Rune.WBG_Sale = 25;
                            Rune.Count = 0;
                            break;
                    }
                }
    
                return Runes;
            }
        }
    }
    

    The issue I'm having currently is my list is empty. I would like it to contain all my runes in the Runes Class and then loop through the list and build the properties for the Runes:

     public List<WBG_Runes> Get_WBG_Runes()
            {
                List<WBG_Runes> Runes = new List<WBG_Runes>();
    
                foreach(var Rune in Runes)
                {

    Something is wrong in my list logic. 

    Thursday, March 14, 2019 7:46 PM

Answers

  • Hi old_School,

    Thank you for posting here.

    For your question, if you want to foreach the list, the list need contain all the data. I use the code below to add data to list. Please take for reference. 

     public class Base_Rune
        {
            /// <summary>
            /// Displayed Name
            /// </summary>
            public string Name { get; set; }
            /// <summary>
            /// Item Count
            /// </summary>
            public long Count { get; set; }
            /// <summary>
            /// Attributes added to socketed items
            /// </summary>
            public List<string> attributes { get; set; }
            /// <summary>
            /// NPC Cost Displayed In NPC Shop
            /// </summary>
            public long NPC_Sale { get; set; }
            /// <summary>
            /// Amount NPC Will give to player for item
            /// </summary>
            public long NPC_Buy { get; set; }
            /// <summary>
            /// WBG Store Cost
            /// </summary>
            public long WBG_Sale { get; set; }
        }
        public class WBG_Runes : Base_Rune
        {
            public string Ancient_Stone { get; set; }
            public string Polished_Ancient_Stone { get; set; }
            public string Rune_a { get; set; }
            public string Rune_da { get; set; }
            public string Rune_ja { get; set; }
            public string Rune_ka { get; set; }
            public string Rune_ma { get; set; }
            public string Rune_na { get; set; }
            public string Rune_pa { get; set; }
            public string Rune_ra { get; set; }
            public string Rune_sa { get; set; }
            public string Rune_ta { get; set; }
            public string Rune_wa { get; set; }
            public string Rune_za { get; set; }
            public string Rune_e { get; set; }
            public string Rune_de { get; set; }
            public string Rune_je { get; set; }
            public string Rune_ke { get; set; }
            public string Rune_me { get; set; }
            public string Rune_ne { get; set; }
            public string Rune_pe { get; set; }
            public string Rune_qe { get; set; }
            public string Rune_re { get; set; }
            public string Rune_se { get; set; }
            public string Rune_te { get; set; }
            public string Rune_we { get; set; }
            public string Rune_ze { get; set; }
            public string Rune_i { get; set; }
            public string Rune_di { get; set; }
            public string Rune_ki { get; set; }
            public string Rune_mi { get; set; }
            public string Rune_ni { get; set; }
            public string Rune_pi { get; set; }
            public string Rune_qi { get; set; }
            public string Rune_ri { get; set; }
            public string Rune_si { get; set; }
            public string Rune_ti { get; set; }
            public string Rune_wi { get; set; }
            public string Rune_o { get; set; }
            public string Rune_do { get; set; }
            public string Rune_jo { get; set; }
            public string Rune_ko { get; set; }
            public string Rune_mo { get; set; }
            public string Rune_no { get; set; }
            public string Rune_po { get; set; }
            public string Rune_qo { get; set; }
            public string Rune_ro { get; set; }
            public string Rune_so { get; set; }
            public string Rune_to { get; set; }
            public string Rune_wo { get; set; }
            public string Rune_zo { get; set; }
            public string Rune_u { get; set; }
            public string Rune_du { get; set; }
            public string Rune_ku { get; set; }
            public string Rune_mu { get; set; }
            public string Rune_nu { get; set; }
            public string Rune_pu { get; set; }
            public string Rune_ru { get; set; }
            public string Rune_su { get; set; }
            public string Rune_tu { get; set; }
            public string Rune_zu { get; set; }
    
            public List<WBG_Runes> Get_WBG_Runes()
            {
                string[] s = { "Ancient_Stone", "" };
                List<WBG_Runes> Runes = new List<WBG_Runes>();
    
                WBG_Runes wBG_Runes = new WBG_Runes();
                var properties = typeof(WBG_Runes).GetProperties();/*wBG_Runes.GetType().GetProperties();*/
                int i = 0;
    
    
                foreach (var item in properties)
                {
                    string rune = properties[i].Name;
                    switch (rune)
                    {
    
                        case "Ancient_Stone":
                            Runes.Add(new WBG_Runes
                            {
                                Name = "Ancient Stone",
                                NPC_Sale = 15,
                                NPC_Buy = 1,
                                WBG_Sale = 20,
                                Count = 0
                            });
                            break;
                        case "Polished_Ancient_Stone":
                            Runes.Add(new WBG_Runes
                            {
                                Name = "Polished Ancient Stone",
                                NPC_Sale = 25,
                                NPC_Buy = 3,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_a":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_da":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0,
                            });
                            break;
                        case "Rune_ja":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ka":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ma":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_na":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_pa":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ra":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_sa":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ta":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_wa":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_za":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_e":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_de":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_je":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ke":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_me":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ne":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_pe":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_qe":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_re":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_se":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_te":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_we":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ze":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_i":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_di":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ki":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_mi":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ni":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_pi":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_qi":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ri":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            Count = 0;
                            break;
                        case "Rune_si":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ti":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_wi":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_o":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_do":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_jo":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ko":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_mo":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_no":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_po":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_qo":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ro":
                            Name = rune.Replace("Rune_", "");
                            NPC_Sale = 30;
                            NPC_Buy = 5;
                            WBG_Sale = 25;
                            Count = 0;
                            break;
                        case "Rune_so":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_to":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_wo":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_zo":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_u":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_du":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ku":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_mu":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_nu":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_pu":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ru":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_su":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_tu":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_zu":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                    }
                    i++;
                }
    
                return Runes;
            }
        }
        class Program
        {
            public static void Main()
            {
    
                WBG_Runes wBG_ = new WBG_Runes();
                wBG_.Get_WBG_Runes();
            }
    
        }

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 15, 2019 7:41 AM
    Moderator

All replies

  • Errrr... it doesn't make any sense the way you have written it. You are creating an empty list with this code:

    List<WBG_Runes> Runes = new List<WBG_Runes>();

    and then you are looping through the members of this list. Since the list is empty, the loop will never execute any of the code that it contains.

    Apparently, you have created a class with many fields named Rune_Something and then you want to loop through the fields. Emphasis on "fields". They are not "Runes", and they are all in the same class (not in multiple instances of the class). You cannot loop through them unless you resort to using Reflection, which is complex and anyway is not what you want to do.

    You need to give it a serious rethink. It has to be very different from what you have now.


    Thursday, March 14, 2019 8:56 PM
    Moderator
  • I don't know maybe it will help you.

    https://dzone.com/articles/different-ways-of-creating-list-of-objects-in-c

    https://www.c-sharpcorner.com/UploadFile/mahesh/create-a-list-of-objects-in-C-Sharp/

    Friday, March 15, 2019 3:20 AM
  • Greetings Old_School.

    Alberto is right. Your code is a mess.

    I'm not certain, but I think you are trying to do something like the following code snippet (greatly compressed, including stripping out most comments, to make it more concise for the purpose of the example).

    class Program { static void Main(string[] args) { // Use the list of runes defined below. RuneList runes = new RuneList(); foreach (Rune r in runes) { Console.WriteLine(r.Name + " " + r.NPC_Sale.ToString() + " " + r.NPC_Buy.ToString() + " " + r.WBG_Sale.ToString()); } } /// <summary> /// A class to hold one rune. /// </summary> public class Rune { public string Name { get; set; } public long Count { get; set; } public List<string> attributes { get; set; } public long NPC_Sale { get; set; } public long NPC_Buy { get; set; } public long WBG_Sale { get; set; } public Rune(string name, long npcSale, long npcBuy, long wbgSale) { Name = name; NPC_Sale = npcSale; NPC_Buy = npcBuy; WBG_Sale = wbgSale; Count = 0; attributes = new List<string>(); } } /// <summary> /// A class to hold a list of standard runes; /// </summary> public class RuneList : List<Rune> // Use the standard List class as a base. {

    // Fill in the list in the constructor. public RuneList() { Add(new Rune("Ancient Stone", 15, 1, 20)); Add(new Rune("Polished Ancient Stone", 25, 3, 25)); Add(new Rune("a", 30, 5, 25)); // And so on, filling out the list. } } }

    The output is like so;

    Friday, March 15, 2019 4:00 AM
  • Hi old_School,

    Thank you for posting here.

    For your question, if you want to foreach the list, the list need contain all the data. I use the code below to add data to list. Please take for reference. 

     public class Base_Rune
        {
            /// <summary>
            /// Displayed Name
            /// </summary>
            public string Name { get; set; }
            /// <summary>
            /// Item Count
            /// </summary>
            public long Count { get; set; }
            /// <summary>
            /// Attributes added to socketed items
            /// </summary>
            public List<string> attributes { get; set; }
            /// <summary>
            /// NPC Cost Displayed In NPC Shop
            /// </summary>
            public long NPC_Sale { get; set; }
            /// <summary>
            /// Amount NPC Will give to player for item
            /// </summary>
            public long NPC_Buy { get; set; }
            /// <summary>
            /// WBG Store Cost
            /// </summary>
            public long WBG_Sale { get; set; }
        }
        public class WBG_Runes : Base_Rune
        {
            public string Ancient_Stone { get; set; }
            public string Polished_Ancient_Stone { get; set; }
            public string Rune_a { get; set; }
            public string Rune_da { get; set; }
            public string Rune_ja { get; set; }
            public string Rune_ka { get; set; }
            public string Rune_ma { get; set; }
            public string Rune_na { get; set; }
            public string Rune_pa { get; set; }
            public string Rune_ra { get; set; }
            public string Rune_sa { get; set; }
            public string Rune_ta { get; set; }
            public string Rune_wa { get; set; }
            public string Rune_za { get; set; }
            public string Rune_e { get; set; }
            public string Rune_de { get; set; }
            public string Rune_je { get; set; }
            public string Rune_ke { get; set; }
            public string Rune_me { get; set; }
            public string Rune_ne { get; set; }
            public string Rune_pe { get; set; }
            public string Rune_qe { get; set; }
            public string Rune_re { get; set; }
            public string Rune_se { get; set; }
            public string Rune_te { get; set; }
            public string Rune_we { get; set; }
            public string Rune_ze { get; set; }
            public string Rune_i { get; set; }
            public string Rune_di { get; set; }
            public string Rune_ki { get; set; }
            public string Rune_mi { get; set; }
            public string Rune_ni { get; set; }
            public string Rune_pi { get; set; }
            public string Rune_qi { get; set; }
            public string Rune_ri { get; set; }
            public string Rune_si { get; set; }
            public string Rune_ti { get; set; }
            public string Rune_wi { get; set; }
            public string Rune_o { get; set; }
            public string Rune_do { get; set; }
            public string Rune_jo { get; set; }
            public string Rune_ko { get; set; }
            public string Rune_mo { get; set; }
            public string Rune_no { get; set; }
            public string Rune_po { get; set; }
            public string Rune_qo { get; set; }
            public string Rune_ro { get; set; }
            public string Rune_so { get; set; }
            public string Rune_to { get; set; }
            public string Rune_wo { get; set; }
            public string Rune_zo { get; set; }
            public string Rune_u { get; set; }
            public string Rune_du { get; set; }
            public string Rune_ku { get; set; }
            public string Rune_mu { get; set; }
            public string Rune_nu { get; set; }
            public string Rune_pu { get; set; }
            public string Rune_ru { get; set; }
            public string Rune_su { get; set; }
            public string Rune_tu { get; set; }
            public string Rune_zu { get; set; }
    
            public List<WBG_Runes> Get_WBG_Runes()
            {
                string[] s = { "Ancient_Stone", "" };
                List<WBG_Runes> Runes = new List<WBG_Runes>();
    
                WBG_Runes wBG_Runes = new WBG_Runes();
                var properties = typeof(WBG_Runes).GetProperties();/*wBG_Runes.GetType().GetProperties();*/
                int i = 0;
    
    
                foreach (var item in properties)
                {
                    string rune = properties[i].Name;
                    switch (rune)
                    {
    
                        case "Ancient_Stone":
                            Runes.Add(new WBG_Runes
                            {
                                Name = "Ancient Stone",
                                NPC_Sale = 15,
                                NPC_Buy = 1,
                                WBG_Sale = 20,
                                Count = 0
                            });
                            break;
                        case "Polished_Ancient_Stone":
                            Runes.Add(new WBG_Runes
                            {
                                Name = "Polished Ancient Stone",
                                NPC_Sale = 25,
                                NPC_Buy = 3,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_a":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_da":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0,
                            });
                            break;
                        case "Rune_ja":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ka":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ma":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_na":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_pa":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ra":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_sa":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ta":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_wa":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_za":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_e":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_de":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_je":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ke":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_me":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ne":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_pe":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_qe":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_re":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_se":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_te":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_we":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ze":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_i":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_di":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ki":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_mi":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ni":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_pi":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_qi":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ri":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            Count = 0;
                            break;
                        case "Rune_si":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ti":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_wi":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_o":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_do":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_jo":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ko":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_mo":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_no":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_po":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_qo":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ro":
                            Name = rune.Replace("Rune_", "");
                            NPC_Sale = 30;
                            NPC_Buy = 5;
                            WBG_Sale = 25;
                            Count = 0;
                            break;
                        case "Rune_so":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_to":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_wo":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_zo":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_u":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_du":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ku":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_mu":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_nu":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_pu":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_ru":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_su":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_tu":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                        case "Rune_zu":
                            Runes.Add(new WBG_Runes
                            {
                                Name = rune.Replace("Rune_", ""),
                                NPC_Sale = 30,
                                NPC_Buy = 5,
                                WBG_Sale = 25,
                                Count = 0
                            });
                            break;
                    }
                    i++;
                }
    
                return Runes;
            }
        }
        class Program
        {
            public static void Main()
            {
    
                WBG_Runes wBG_ = new WBG_Runes();
                wBG_.Get_WBG_Runes();
            }
    
        }

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 15, 2019 7:41 AM
    Moderator
  • Why are you using a switch case in this sitiuation? And a lot of parts in your code are duplicates. For refactoring purpose I would change it.

    Have a nice day ahead...

    Friday, March 15, 2019 9:06 AM
  • Wendy has the correct answer but I'm curious based on other peoples thoughts. How would the syntax look then if I created a individual class for each item then but inherit my base Rune class? I tried this earlier but could not get it to allow me to access the base rune properties to define them. 
    Friday, March 15, 2019 6:25 PM
  • Hi old_School,

    I do not understand what you want. Could you provide more details?

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 18, 2019 7:05 AM
    Moderator
  • The other guys where suggesting I format my Rune class differently I was asking them how they suggested I setup the Rune object instead of how I built it presently. 

    I'm going to create a separate thread because we are starting to get off topic and you already answered the question. 

    • Edited by old_School Monday, March 18, 2019 6:45 PM
    Monday, March 18, 2019 6:41 PM