The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,418 other followers

Archive for September 4th, 2018

c# – All possible array initialization syntaxes – Stack Overflow

Posted by jpluimers on 2018/09/04

Since I tend to forget in-line array expression: [Archive.is] c# – All possible array initialization syntaxes – Stack Overflow:

These are the current declaration and initialization methods for a simple array.
string[] array = new string[2]; // creates array of length 2, default values
string[] array = new string[] { "A", "B" }; // creates populated array of length 2
string[] array = { "A" , "B" }; // creates populated array of length 2
string[] array = new[] { "A", "B" }; // created populated array of length 2
Also note that in the declarations above, the first two could replace the string[] on the left with var (C# 3+), as the information on the right is enough to infer the proper type. The third line must be written as displayed, as array initialization syntax alone is not enough to satisfy the compiler’s demands. The fourth could also use inference. So if you’re into the whole brevity thing, the above could be written as
var array = new string[2]; // creates array of length 2, default values
var array = new string[] { "A", "B" }; // creates populated array of length 2
string[] array = { "A" , "B" }; // creates populated array of length 2
var array = new[] { "A", "B" }; // created populated array of length 2 

–jeroen

Posted in .NET, C#, Development, Software Development | Leave a Comment »

What are your favorite extension methods for C#? (codeplex.com/extensionoverflow) – Stack Overflow

Posted by jpluimers on 2018/09/04

From an archive a long time ago: by now this question is probably deleted because well Stack Overflow:

Explanations how they work: [WayBackhttp://stackoverflow.com/questions/4338333/object-how-top-most-base-class-got-method/4338509

The codeplex repository https://extensionoverflow.codeplex.com has been forked at https://github.com/devkhan/ExtensionOverflow

–jeroej

Posted in .NET, C#, Development, Software Development | Leave a Comment »

How and when are variables referenced in Delphi’s anonymous methods captured? – Stack Overflow

Posted by jpluimers on 2018/09/04

Just found some notes from 2013 for my research list that are still relevant:

–jeroen

Posted in Delphi, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, Software Development | Leave a Comment »

 
%d bloggers like this: