Click here to Skip to main content
14,576,970 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: Coding question (for your morning entertainment) Pin
honey the codewitch24-Feb-20 4:34
mvahoney the codewitch24-Feb-20 4:34 
GeneralRe: Coding question (for your morning entertainment) Pin
ZurdoDev24-Feb-20 4:58
mveZurdoDev24-Feb-20 4:58 
GeneralRe: Coding question (for your morning entertainment) Pin
DRHuff24-Feb-20 5:17
MemberDRHuff24-Feb-20 5:17 
GeneralRe: Coding question (for your morning entertainment) Pin
Nelek24-Feb-20 5:21
protectorNelek24-Feb-20 5:21 
AnswerRe: Coding question (for your morning entertainment) Pin
ZurdoDev24-Feb-20 5:26
mveZurdoDev24-Feb-20 5:26 
JokeRe: Coding question (for your morning entertainment) Pin
Mycroft Holmes24-Feb-20 12:29
professionalMycroft Holmes24-Feb-20 12:29 
GeneralRe: Coding question (for your morning entertainment) Pin
DRHuff24-Feb-20 14:04
MemberDRHuff24-Feb-20 14:04 
GeneralRe: Coding question (for your morning entertainment) Pin
Sander Rossel24-Feb-20 6:22
professionalSander Rossel24-Feb-20 6:22 
I do have a small issue with your extension method.
It returns an array instead of an IEnumerable like everything else in LINQ.
That means it's directly evaluated even though you may not expect it (the original Repeat function isn't).
I guess you could rename it to RepeatToArray, but you'd possibly need an RepeatToList as well, and just naming it Repeat and returning an IEnumerable and then calling ToArray is almost the same...
Also, your Repeat extension method extends every possible object in .NET, which isn't a very good practice.
I imagine you don't need it everywhere, so maybe an internal extension method would be better.
Or it would need its own namespace so you always have to explicitly import it.

Having said all that, I prefer the second method.
To me, it's the best readable version and also the best performant in terms of memory and CPU (theoretically, because we're talking nanoseconds here).

GeneralRe: Coding question (for your morning entertainment) Pin
Richard Deeming24-Feb-20 9:09
mveRichard Deeming24-Feb-20 9:09 
GeneralRe: Coding question (for your morning entertainment) Pin
BillWoodruff26-Feb-20 5:38
mveBillWoodruff26-Feb-20 5:38 
GeneralRe: Coding question (for your morning entertainment) Pin
BillWoodruff25-Feb-20 23:47
mveBillWoodruff25-Feb-20 23:47 
GeneralWell, there's lucky Pin
Mark_Wallace24-Feb-20 3:54
MemberMark_Wallace24-Feb-20 3:54 
GeneralRe: Well, there's lucky Pin
dandy7225-Feb-20 4:46
Memberdandy7225-Feb-20 4:46 
GeneralRe: Well, there's lucky Pin
Mark_Wallace25-Feb-20 6:29
MemberMark_Wallace25-Feb-20 6:29 
GeneralRe: Well, there's lucky Pin
dandy7225-Feb-20 9:22
Memberdandy7225-Feb-20 9:22 
GeneralRe: Well, there's lucky Pin
Gary Wheeler25-Feb-20 6:02
MemberGary Wheeler25-Feb-20 6:02 
GeneralRe: Well, there's lucky Pin
Mark_Wallace25-Feb-20 6:25
MemberMark_Wallace25-Feb-20 6:25 
GeneralRe: Well, there's lucky Pin
dandy7225-Feb-20 9:37
Memberdandy7225-Feb-20 9:37 
GeneralC'mon M$... seriously? Pin
Nelek24-Feb-20 3:29
protectorNelek24-Feb-20 3:29 
GeneralRe: C'mon M$... seriously? Pin
Mark_Wallace24-Feb-20 3:34
MemberMark_Wallace24-Feb-20 3:34 
GeneralRe: C'mon M$... seriously? Pin
Nelek24-Feb-20 4:27
protectorNelek24-Feb-20 4:27 
GeneralRe: C'mon M$... seriously? Pin
musefan24-Feb-20 3:37
Membermusefan24-Feb-20 3:37 
GeneralRe: C'mon M$... seriously? Pin
Nelek24-Feb-20 4:29
protectorNelek24-Feb-20 4:29 
QuestionRe: C'mon M$... seriously? Pin
ZurdoDev24-Feb-20 3:44
mveZurdoDev24-Feb-20 3:44 
AnswerRe: C'mon M$... seriously? Pin
Nelek24-Feb-20 4:31
protectorNelek24-Feb-20 4:31 

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.