Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- myList.ForEach(a => { if (a.Trim().Length == 0) a = "0.0"; })
- for (Int32 index = 0; index < myList.Count; index++)
- if (myList[index].Trim().Length == 0)
- myList[index] = "0.0";
- myList = (from a in myList
- select (a.Trim().Length == 0) ? "0.0" : a).ToList();
- myList = myList.Select(a => (a.Trim().Length == 0) ? "0.0" : a).ToList();
- List<Double> myDoubleList =
- (from a in myList
- select (a.Trim().Length == 0 ? "0" : a) into d
- select Double.Parse(d)).ToList();
- List<Double> myDoubleList =
- (from a in myList
- select (a.Trim().Length == 0 ? "0.0" : a) into d
- select Double.Parse(d, CultureInfo.InvariantCulture)).ToList();
- public static void MutateEach(this IList<T> list, Func<T, T> mutator)
- {
- int count = list.Count;
- for (int n = 0; n < count; n++)
- list[n] = mutator(list[n]);
- }
- myList.MutateEach(a => (a.Trim().Length == 0) ? "0.0" : a);
Add Comment
Please, Sign In to add comment