sort in Ascending Order [closed]

Did little example to understand object parsing into int type parameter.

List<object> _obj = new List<object>() { "10", "20", "30", "d", "a", "t" };

int sum = 0;

for (int i = 0; i < _obj.Count; i++)
{
    int temp;

    //parsing object into int type, when we cant parse object will be 0
    int.TryParse(_obj[i].ToString(), out temp);

    //sum values
    sum = sum + temp;
}

Leave a Comment