Click here to Skip to main content
15,895,557 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to organize this data Pin
SledgeHammer0129-Dec-14 14:58
SledgeHammer0129-Dec-14 14:58 
GeneralRe: How to organize this data Pin
BillWoodruff29-Dec-14 23:44
professionalBillWoodruff29-Dec-14 23:44 
GeneralRe: How to organize this data Pin
SledgeHammer0130-Dec-14 4:13
SledgeHammer0130-Dec-14 4:13 
GeneralRe: How to organize this data Pin
PIEBALDconsult29-Dec-14 13:07
mvePIEBALDconsult29-Dec-14 13:07 
GeneralRe: How to organize this data Pin
BillWoodruff29-Dec-14 23:15
professionalBillWoodruff29-Dec-14 23:15 
GeneralRe: How to organize this data Pin
SledgeHammer0130-Dec-14 4:17
SledgeHammer0130-Dec-14 4:17 
GeneralRe: How to organize this data Pin
BillWoodruff30-Dec-14 23:42
professionalBillWoodruff30-Dec-14 23:42 
GeneralRe: How to organize this data Pin
PIEBALDconsult30-Dec-14 15:29
mvePIEBALDconsult30-Dec-14 15:29 
BillWoodruff wrote:
the code I write here is meant to be "educational;"


Then please don't lead newbies down the rabbit hole of bad Linq -- show them only the One True Path because they will think your code is "best practice".


BillWoodruff wrote:
does not make a copy in the sense of a "deep copy;"


It's still a needless copy; it's still very bad, and newbies won't know the difference.

Furthermore, if your method is generic, unless it specifies a struct constraint), it won't know whether the data is value-type or not. In practice, it's not a worthwhile distinction; don't make any needless copies of anything.


Furthermore, consider some collection and a chain of n Linq/Lambda filters, each of which returns a List rather than a simple enumerator. You've copied the each datum (values or references I don't care) n times.
With the same n tasks performed with only one ToList at the end, you copy each datum only once.
-- The foregoing is likely over-simplified and not strictly true, because the enumerators involved also copy the data one-by-one as it passes through, so perhaps there are 2n copies "your way" and n+1 copies "my way".
Another thing I want to point out is that the final task might be "take 10" (or similar) which means "my way" only iterates and copies those 10 data, not all of them -- whereas calling ToList at intermediate steps will cause a lot of needless intermediate copying.
GeneralRe: How to organize this data Pin
BillWoodruff30-Dec-14 23:53
professionalBillWoodruff30-Dec-14 23:53 
GeneralMessage Closed Pin
29-Dec-14 2:32
Marvic Grima29-Dec-14 2:32 
Questionserial port CreateFile in c# Pin
Member 1114321929-Dec-14 2:16
Member 1114321929-Dec-14 2:16 
AnswerRe: serial port CreateFile in c# Pin
OriginalGriff29-Dec-14 2:28
mveOriginalGriff29-Dec-14 2:28 
GeneralRe: serial port CreateFile in c# Pin
Member 1114321929-Dec-14 2:45
Member 1114321929-Dec-14 2:45 
GeneralRe: serial port CreateFile in c# Pin
Member 1114321929-Dec-14 2:55
Member 1114321929-Dec-14 2:55 
GeneralRe: serial port CreateFile in c# Pin
OriginalGriff29-Dec-14 3:42
mveOriginalGriff29-Dec-14 3:42 
Questionusing SqlConncetion Pin
Jassim Rahma29-Dec-14 1:16
Jassim Rahma29-Dec-14 1:16 
AnswerRe: using SqlConncetion Pin
OriginalGriff29-Dec-14 2:02
mveOriginalGriff29-Dec-14 2:02 
AnswerRe: using SqlConncetion Pin
Dominic Burford30-Dec-14 5:52
professionalDominic Burford30-Dec-14 5:52 
QuestionObj.Orientation structure newbie/intermediate question Pin
BlindNavigator29-Dec-14 0:04
BlindNavigator29-Dec-14 0:04 
AnswerRe: Obj.Orientation structure newbie/intermediate question Pin
Pete O'Hanlon29-Dec-14 4:45
mvePete O'Hanlon29-Dec-14 4:45 
GeneralRe: Obj.Orientation structure newbie/intermediate question Pin
BlindNavigator29-Dec-14 5:37
BlindNavigator29-Dec-14 5:37 
AnswerRe: Obj.Orientation structure newbie/intermediate question Pin
BillWoodruff29-Dec-14 5:17
professionalBillWoodruff29-Dec-14 5:17 
QuestionWorkFlow Pin
Zeyad Jalil28-Dec-14 20:58
professionalZeyad Jalil28-Dec-14 20:58 
AnswerRe: WorkFlow Pin
Pete O'Hanlon28-Dec-14 21:21
mvePete O'Hanlon28-Dec-14 21:21 
QuestionCreate diagonal in the DevExpress XtraReport Pin
nhanlaptrinh28-Dec-14 1:42
nhanlaptrinh28-Dec-14 1:42 

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.