1. Hello,

    First of all sorry if you think i am really dumb but i am not an expert of c# developpement.

    I got a class Rewards :

    Code:
            class Rewards
            {
                public int price;
                public Dictionary<string, int> reward;
            }
    
    And i load my List from config, it look like :

    Code:
    "Rewards": [
          {
            "price": 1,
            "reward": {
              "wall#external#high#stone": 100
            }
          },
          {
            "price": 2,
            "reward": {
              "weapon#mod#small#scope": 4
            }
          }
    ]
    The list is loaded as object because oxide want it..
    I am trying to cast this list from config like
    Code:
    Rewards items = (Rewards) Reward[index - 1];
    assuming Reward is the List<object> from config.
    but i get this error :
    "Cannot cast from source type to destination type."

    i am trying to get something like

    Code:
    Rewards items = (Rewards) Reward[index - 1];items.price
    items.reward //where this is a Dictionary<string, int>
    Thanks for your help & sorry for my english :/
     
  2. I know very little too :D but maybe try
    Code:
    var items = Reward[index - 1] as Rewards;
     
    Last edited by a moderator: Feb 16, 2017