|
-
Jun 14th, 2011, 02:45 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] long? CompareTo
the type 'long' has a 'compareto()' method but how would you do it if the variable is type 'long?' ?
Basically got a class that contains a variable called FileSize which contains null if it is a folder and other files should have a value for it..so for sorting the specific field, I will need to do a 'compareTo()' but don't seem to do it.
Any ideas? Thanks
Please go to the Thread Tools menu and click Mark Thread Resolved when your post is answered 
If someone helped you today then please consider rating their post.
-
Jun 14th, 2011, 05:56 AM
#2
Re: long? CompareTo
nullable<long> has a Compare method if it's any help.
You can also specify your own comparison methods.
-
Jun 14th, 2011, 06:59 AM
#3
Thread Starter
Hyperactive Member
Re: long? CompareTo
Thanks for the reply..
am I doing something wrong with this code then?
Code:
Nullable.Compare<FileSystemItem>(item1.Size, item2.Size);
Please go to the Thread Tools menu and click Mark Thread Resolved when your post is answered 
If someone helped you today then please consider rating their post.
-
Jun 14th, 2011, 07:14 AM
#4
Re: long? CompareTo
Are you comparing nullable FileSystemItems or nullable longs?
Code:
int comp = Nullable.Compare<long>(item1.Size, item2.Size);
//or
int comp = Nullable.Compare(item1.Size, item2.Size);
-
Jun 14th, 2011, 08:34 AM
#5
Thread Starter
Hyperactive Member
Re: long? CompareTo
The latter line of code worked wonders.
Thanks very much ^_^
Please go to the Thread Tools menu and click Mark Thread Resolved when your post is answered 
If someone helped you today then please consider rating their post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|