Click here to Skip to main content
14,975,726 members
Home / Discussions / C#
   

C#

 
AnswerRe: Need help with straight line depreciation coding Pin
OriginalGriff21-Jun-21 9:21
mveOriginalGriff21-Jun-21 9:21 
GeneralRe: Need help with straight line depreciation coding Pin
Member 1524886721-Jun-21 9:24
MemberMember 1524886721-Jun-21 9:24 
GeneralRe: Need help with straight line depreciation coding Pin
OriginalGriff21-Jun-21 9:58
mveOriginalGriff21-Jun-21 9:58 
GeneralRe: Need help with straight line depreciation coding Pin
Member 1524886721-Jun-21 10:54
MemberMember 1524886721-Jun-21 10:54 
GeneralRe: Need help with straight line depreciation coding Pin
Mycroft Holmes21-Jun-21 13:53
professionalMycroft Holmes21-Jun-21 13:53 
AnswerRe: Need help with straight line depreciation coding Pin
Gerry Schmitz22-Jun-21 6:27
mveGerry Schmitz22-Jun-21 6:27 
Questionc# language feature surprise using Linq ThenBy (observation) Pin
BillWoodruff20-Jun-21 23:40
mveBillWoodruff20-Jun-21 23:40 
AnswerRe: c# language feature surprise using Linq ThenBy (observation) Pin
Richard Deeming21-Jun-21 1:29
mveRichard Deeming21-Jun-21 1:29 
As far as I can see, the LINQ ThenBy extension method only works if the argument type is IOrderedEnumerable<T> or IOrderedQueryable<T>. If you try to call it on an IEnumerable<T> or IQueryable<T>, you'll get a CS1061 compiler error even if the run-time type is an ordered enumerable/query.

Enumerable.ThenBy Method (System.Linq) | Microsoft Docs[^]
Queryable.ThenBy Method (System.Linq) | Microsoft Docs[^]

So these will work:
C#
// Works:
IEnumerable<T> source = ...;
IOrderedEnumerable<T> result = source.OrderBy(x => x.Foo).ThenBy(x => x.Bar);

// Works:
IEnumerable<T> source = ...;
IOrderedEnumerable<T> sorted = source.OrderBy(x => x.Foo);
IOrderedEnumerable<T> result = sorted.ThenBy(x => x.Bar);
But these will not:
C#
// Doesn't compile:
IEnumerable<T> source = ...;
IOrderedEnumerable<T> result = source.OrderBy(x => x.Foo).Where(x => x.IsActive).ThenBy(x => x.Bar);

// Doesn't compile:
IEnumerable<T> source = ...;
IOrderedEnumerable<T> sorted = source.OrderBy(x => x.Foo);
IOrderedEnumerable<T> result = sorted.Where(x => x.IsActive).ThenBy(x => x.Bar);

// Doesn't compile:
IEnumerable<T> source = ...;
IOrderedEnumerable<T> result = source.OrderBy(x => x.Foo).AsEnumerable().ThenBy(x => x.Bar);

// Doesn't compile:
IEnumerable<T> source = ...;
IOrderedEnumerable<T> sorted = source.OrderBy(x => x.Foo);
IOrderedEnumerable<T> result = sorted.AsEnumerable().ThenBy(x => x.Bar);
Of course, if you're using reflection or the LINQ Expressions API, then a call to ThenBy should work, so long as the parameter has the correct run-time type.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: c# language feature surprise using Linq ThenBy (observation) Pin
BillWoodruff21-Jun-21 2:38
mveBillWoodruff21-Jun-21 2:38 
Questioncan any one please explain how to connect to stratum 1 or 2 mining pool? Pin
Member 1336047319-Jun-21 7:11
MemberMember 1336047319-Jun-21 7:11 
AnswerRe: can any one please explain how to connect to stratum 1 or 2 mining pool? Pin
OriginalGriff19-Jun-21 9:12
mveOriginalGriff19-Jun-21 9:12 
AnswerRe: can any one please explain how to connect to stratum 1 or 2 mining pool? Pin
BillWoodruff20-Jun-21 23:29
mveBillWoodruff20-Jun-21 23:29 
QuestionPrinte page limit Pin
Member 1419221619-Jun-21 5:46
MemberMember 1419221619-Jun-21 5:46 
QuestionDelegates, generic collection Pin
Samkelo3418-Jun-21 11:41
MemberSamkelo3418-Jun-21 11:41 
AnswerRe: Delegates, generic collection Pin
OriginalGriff18-Jun-21 11:42
mveOriginalGriff18-Jun-21 11:42 
AnswerRe: Delegates, generic collection Pin
Mycroft Holmes18-Jun-21 12:39
professionalMycroft Holmes18-Jun-21 12:39 
JokeRe: Delegates, generic collection Pin
Peter_in_278018-Jun-21 15:03
professionalPeter_in_278018-Jun-21 15:03 
AnswerRe: Delegates, generic collection Pin
Richard MacCutchan18-Jun-21 22:20
mveRichard MacCutchan18-Jun-21 22:20 
Questionhow to remove node from string formatted xml using c# Pin
michael nabil18-Jun-21 11:07
Membermichael nabil18-Jun-21 11:07 
AnswerRe: how to remove node from string formatted xml using c# Pin
Richard MacCutchan18-Jun-21 22:15
mveRichard MacCutchan18-Jun-21 22:15 
AnswerRe: how to remove node from string formatted xml using c# Pin
Richard Deeming20-Jun-21 23:22
mveRichard Deeming20-Jun-21 23:22 
GeneralRe: how to remove node from string formatted xml using c# Pin
michael nabil21-Jun-21 10:31
Membermichael nabil21-Jun-21 10:31 
QuestionShared memory Pin
manoharbalu18-Jun-21 2:26
Membermanoharbalu18-Jun-21 2:26 
AnswerRe: Shared memory Pin
Richard Andrew x6419-Jun-21 14:39
professionalRichard Andrew x6419-Jun-21 14:39 
GeneralRe: Shared memory Pin
manoharbalu21-Jun-21 1:15
Membermanoharbalu21-Jun-21 1:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.