Can we avoid multiple if''s(C#3.0)
        Posted  
        
            by Newbie
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Newbie
        
        
        
        Published on 2010-05-07T13:45:49Z
        Indexed on 
            2010/05/07
            13:48 UTC
        
        
        Read the original article
        Hit count: 143
        
c#3.0
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
© Stack Overflow or respective owner