Can we avoid multiple if''s?
- by Newbie
I tried my level best to write an improved version but failed.
inFiles.ToList().ForEach(i =>
{
filePath = inFolder + "\\" + i.Value;
if (i.Key.Equals(replacementFile))
{
replacementCollection = GetReplacementDataFromFile(filePath);
}
else if (i.Key.Equals(standardizationFile))
{
standardizationCollection = GetStandardizationDataFromFile(filePath);
}
});
The problem is that I cannot use a switch case over here because the comparison variables are not constant.
Kindly help to improve this code.
I am using C#(3.0).
Thanks