Sorting List which has object that contains two string members that contains numbers

Posted by Lemo on Stack Overflow See other posts from Stack Overflow or by Lemo
Published on 2014-05-29T15:17:25Z Indexed on 2014/05/29 15:25 UTC
Read the original article Hit count: 365

Filed under:
|
|
|

I want to know the best solution for this

my case here is that i am taking values from Excel sheet and pushing them to database field, sometimes that field might contain some strings (thats why I cant make my object members int / double)

In my class below size is the variable responsible for showing size of files in bytes

public class dataNameValue
{
    public string Name { get; set; }
    public string Count { get; set; }
    public string Size { get; set; }
}

I wanted to sort the list by file Size something like

List mylist = new List(); mylist = mylist.OrderByDescending(i => i.Size).ToList();

The problem is that if i sorted it without converting it to "int/double" first -- its not giving right results

enter image description here

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET