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 :
And i load my List from config, it look like :Code:class Rewards { public int price; public Dictionary<string, int> reward; }
The list is loaded as object because oxide want it..Code:"Rewards": [ { "price": 1, "reward": { "wall#external#high#stone": 100 } }, { "price": 2, "reward": { "weapon#mod#small#scope": 4 } } ]
I am trying to cast this list from config like
assuming Reward is the List<object> from config.Code:Rewards items = (Rewards) Reward[index - 1];
but i get this error :
"Cannot cast from source type to destination type."
i am trying to get something like
Thanks for your help & sorry for my english :/Code:Rewards items = (Rewards) Reward[index - 1];items.price items.reward //where this is a Dictionary<string, int>
List<object> to List<class>
Discussion in 'Rust Development' started by sami37, Feb 16, 2017.