Guest User

Untitled

a guest
Jun 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. myList.ForEach(a => { if (a.Trim().Length == 0) a = "0.0"; })
  2.  
  3. for (Int32 index = 0; index < myList.Count; index++)
  4. if (myList[index].Trim().Length == 0)
  5. myList[index] = "0.0";
  6.  
  7. myList = (from a in myList
  8. select (a.Trim().Length == 0) ? "0.0" : a).ToList();
  9.  
  10. myList = myList.Select(a => (a.Trim().Length == 0) ? "0.0" : a).ToList();
  11.  
  12. List<Double> myDoubleList =
  13. (from a in myList
  14. select (a.Trim().Length == 0 ? "0" : a) into d
  15. select Double.Parse(d)).ToList();
  16.  
  17. List<Double> myDoubleList =
  18. (from a in myList
  19. select (a.Trim().Length == 0 ? "0.0" : a) into d
  20. select Double.Parse(d, CultureInfo.InvariantCulture)).ToList();
  21.  
  22. public static void MutateEach(this IList<T> list, Func<T, T> mutator)
  23. {
  24. int count = list.Count;
  25. for (int n = 0; n < count; n++)
  26. list[n] = mutator(list[n]);
  27. }
  28.  
  29. myList.MutateEach(a => (a.Trim().Length == 0) ? "0.0" : a);
Add Comment
Please, Sign In to add comment