Sunday, July 7, 2013

an old school foreach may be the most readable sometimes in my opinion

Using ReSharper on the Get method here, I was able to condense everything but the first two lines (unaltered) and last line (also unaltered) into one line of code. However, I don't know that it is terribly easy to understand, you know?

foreach (string scrapping in from scrapping in scrappings where scrapping.IndexOf(".") > -1 let subscrappings = scrapping.Split(".".ToCharArray()) where subscrappings.Length == 4 && ip == null select scrapping) ip = scrapping.Split("<".ToCharArray())[0].ToLower().Where(character => IsCharacterOfIp(character)).Aggregate(ip, (current, character) => current + character);

No comments:

Post a Comment