Click here to Skip to main content
14,580,573 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: Well, it's possible to post on CP using a VR helmet... Pin
DRHuff24-Feb-20 5:10
MemberDRHuff24-Feb-20 5:10 
GeneralRe: Well, it's possible to post on CP using a VR helmet... Pin
dandy7225-Feb-20 9:17
Memberdandy7225-Feb-20 9:17 
GeneralRe: Well, it's possible to post on CP using a VR helmet... Pin
Chris Maunder24-Feb-20 8:12
cofounderChris Maunder24-Feb-20 8:12 
GeneralRe: Well, it's possible to post on CP using a VR helmet... Pin
Nelek24-Feb-20 8:32
protectorNelek24-Feb-20 8:32 
GeneralRe: Well, it's possible to post on CP using a VR helmet... Pin
BillWoodruff26-Feb-20 21:01
mveBillWoodruff26-Feb-20 21:01 
GeneralRe: Well, it's possible to post on CP using a VR helmet... Pin
OriginalGriff26-Feb-20 21:21
mveOriginalGriff26-Feb-20 21:21 
GeneralRe: Well, it's possible to post on CP using a VR helmet... Pin
BillWoodruff29-Feb-20 20:34
mveBillWoodruff29-Feb-20 20:34 
GeneralCoding question (for your morning entertainment) Pin
Marc Clifton24-Feb-20 3:58
mvaMarc Clifton24-Feb-20 3:58 
C#: Which do you prefer (given the small number of array items):
Type stringType = typeof(string);
Type[] expectedTypes = Enumerable.Repeat(stringType, 3).ToArray();
or:
Type stringType = typeof(string);
Type[] expectedTypes = new Type[] {stringType, stringType, stringType};
or: (using an extension method):
Type[] expectedTypes = typeof(string).Repeat(3);
Definition of the extension method:
public static T[] Repeat<T>(this T item, int n)
{
    return Enumerable.Repeat(item, n).ToArray();
}

I'm curious if anyone has any strong preference, and why.

From my perspective, the first version is sort of silly but cute, given there's only 3 items being initialized. The second version, ok, but I don't like it because I hate repeating myself. The third version I really like as it's very readable but some people object to creating extension methods (not that I care, it's my code, haha.)

GeneralRe: Coding question (for your morning entertainment) Pin
CPallini24-Feb-20 4:22
mveCPallini24-Feb-20 4:22 
GeneralRe: Coding question (for your morning entertainment) Pin
Gary Wheeler25-Feb-20 5:58
MemberGary Wheeler25-Feb-20 5:58 
GeneralRe: Coding question (for your morning entertainment) Pin
CPallini25-Feb-20 10:07
mveCPallini25-Feb-20 10:07 
GeneralRe: Coding question (for your morning entertainment) Pin
PIEBALDconsult24-Feb-20 4:31
professionalPIEBALDconsult24-Feb-20 4:31 
GeneralRe: Coding question (for your morning entertainment) Pin
Marc Clifton24-Feb-20 4:38
mvaMarc Clifton24-Feb-20 4:38 
GeneralRe: Coding question (for your morning entertainment) Pin
Sander Rossel24-Feb-20 6:11
professionalSander Rossel24-Feb-20 6:11 
GeneralRe: Coding question (for your morning entertainment) Pin
Sander Rossel24-Feb-20 6:11
professionalSander Rossel24-Feb-20 6:11 
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 
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 

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.