A int FindSum(object[] values) { int sum = 0; foreach (object o in values) { if (o is int) { int x = (int) o; sum += x; } } return sum; }
B int FindSum (object[] values) { int sum = 0; foreach (object o in values) { int? x = o as int?; if (x.HasValue) { sum += x.Value; } } return sum; }
C int FindSum (object[] values) { int sum = values.OfType<int>().Sum(); return sum; }
D int FindSum (object[] values) { int sum = 0; foreach (object o in values) { if (o is int) { int x = Convert.ToInt32(o); sum += x; } } return sum; }