Is there a more elegant way to check for items in my dictionary as "Container" is…
- User
Is there a more elegant way to check for items in my dictionary as "Container" is repeating all over again? Dictionary<string, List> ContainerMap = new Dictionary<string, List>{ {StoneContainerKeyword, StoneContainers}, {FeOreContainerKeyword, FeOreContainers}, {MgOreContainerKeyword, MgOreContainers}, {NiOreContainerKeyword, NiOreContainers}, {SiOreContainerKeyword, SiOreContainers}, {CoOreContainerKeyword, CoOreContainers}, {PtOreContainerKeyword, PtOreContainers}, {AgOreContainerKeyword, AgOreContainers}, {AuOreContainerKeyword, AuOreContainers}, {UOreContainerKeyword, UOreContainers}, {FeIngotContainerKeyword, FeIngotContainers}, {MgIngotContainerKeyword, MgIngotContainers}, {NiIngotContainerKeyword, NiIngotContainers}, {SiIngotContainerKeyword, SiIngotContainers}, {CoIngotContainerKeyword, CoIngotContainers}, {PtIngotContainerKeyword, PtIngotContainers}, {AgIngotContainerKeyword, AgIngotContainers}, {AuIngotContainerKeyword, AuIngotContainers}, {UIngotContainerKeyword, UIngotContainers}, {ComponentContainerKeyword, ComponentContainers}, {AmmoContainerKeyword, AmmoContainers}, {SpecialContainerKeyword, SpecialContainer} } bool isTypeContainer = false;
codeforeach(var pair in ContainerMap){ if (blockname.Contains(pair.Key)) { pair.Value.Add(block); isTypeContainer = true; } } - Assistant