Click here to Skip to main content
14,580,566 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
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 
GeneralRe: Coding question (for your morning entertainment) Pin
Richard Deeming24-Feb-20 9:09
mveRichard Deeming24-Feb-20 9:09 
Option 4:
Type[] expectedTypes = { typeof(string), typeof(string), typeof(string) };
No need to repeat the element type, or add the new[] keyword. Smile | :)

ToArray[^] delegates to the internal Buffer<TElement>[^] class. If the input implements ICollection<TElement> (which the result of Repeat doesn't), it declares and returns a single array of the correct size. Otherwise, it starts with an array of four elements; doubles the size each time it runs out of room; and then allocates a final array of the correct size once it's finished.

It's obviously not a huge extra overhead in this case. But it could add up if you're calling the code many times. And I don't think it really makes the code any clearer.



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

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 
GeneralRe: C'mon M$... seriously? Pin
David O'Neil24-Feb-20 5:18
professionalDavid O'Neil24-Feb-20 5:18 

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.