Archive for the ‘C#’ Category
Posted by jpluimers on 2013/01/30
Just in case you wonder about Property using Generics in Delphi, they are not possible.
Thanks David for mentioning it, Hallvard for mentioning it even earlier and Rudy for confirming it.
These are supported with Generics in Delphi:
All of the supported aspects are linked to articles from excellent authors. There is far more on the internet about Delphi and Generics, but those are a good start.
Thanks Malcolm, Phil, Barry, Hallvard, Jolyon and many others for posting all those articles!
Note that this is not possible in C# either, Julian Bucknall organized a chat and explains why, but there is a workaround which I might try to port to Delphi in the future.
–jeroen
via: Property using Generics in Delphi – Stack Overflow.
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | 3 Comments »
Posted by jpluimers on 2013/01/24
During code reviews, I often see people do things like this:
if (!Directory.Exists(directoryPath))
Directory.CreateDirectory(directoryPath);
or this:
DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath);
if (!directoryInfo.Exists)
directoryInfo.Create();
You don’t need the if statements here. Read the rest of this entry »
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | 1 Comment »
Posted by jpluimers on 2013/01/17
Too bad the new StackOverflow rules actively discourage the kind of open questions like “c# – What are your thoughts on Raven DB?“.
They are being closed as “not constructive by casperOne♦ Nov 29 ’11 at 5:25”, which is a shame as these kinds of questions often reveal very valuable and balanced answers.
Right now I’m resarching what RavenDB could mean for storing documents. And yes, I know about the RavenDB licensing model: free for open source, pay for commercial use.
–jeroen
via: c# – What are your thoughts on Raven DB? – Stack Overflow.
Posted in .NET, C#, C# 4.0, C# 5.0, Database Development, Development, Pingback, Software Development, Stackoverflow | Leave a Comment »
Posted by jpluimers on 2013/01/16
Thanks to Danny Thorpe and John Skeet, I learned something about C# initialization order.
I knew there were differences between declarations having their initial value set at the point of declaration, and inside a constructor, but not about all of them.
So I observed the initialization order while stepping through code, but the virtual method behaviour was new to me.
Thanks Blaz Art for asking this at SO.
Danny Thorpe: Read the rest of this entry »
Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Jon Skeet, Software Development | Leave a Comment »
Posted by jpluimers on 2013/01/10
In the .NET 1.x past, the WinForms designers in Visual Studio .NET and Visual Studio 2003 would put the C# or VB.NET code containing the form code as the InitializeComponent method of the top most class monolithic C# and VB.NET files that also contain the user code (for events and such).
As of Visual Studio 2005 (actually: Whidbey and higher), this code is based on partial classes. For each form (actually designable entity, but lets limit this to WinForms forms) you get a MyForm.cs and MyForm.Designer.cs
As a side note, with a bit of effort, you can generate the Windows Form Designer generated code yourself as this answer shows. This is for instance convenient when you have form definitions in a different technology and want to convert it to WinForms, WPF or another form of designer based .NET code.
I long time ago I wrote a short manual for co-workers on converting the monolithic files (for people interested, it is below).
Since then I found a couple of very interesting links: Read the rest of this entry »
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development, Visual Studio 11, Visual Studio 2002, Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools, WinForms | 1 Comment »
Posted by jpluimers on 2013/01/09
Until I realized that comparing two IEnumerables needed some extra thought, I wondered why Assert.AreEqual would not support them.
jrista pointed me in the right direction answering a question about c# – How does Assert.AreEqual determine equality between two generic IEnumerables?
The correct answer is “it doesn’t”, but that is really dense.
IEnumerables are just that: being generic or normal, they allow you to enumerate things. They can get you an enumerator (generic or not) that has a notion of Current (generic or normal) and such, but no knowledge of the underlying data.
Comparing them needs you to think about the enumeration and the underlying data at the same time. You can get two kinds of comparisons: Read the rest of this entry »
Posted in .NET, .NET 3.5, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2013/01/08
When developing in multiple languages, it sometimes is funny to see how they differ in compiler oddities.
Below are a few on const examples.
Basically, in C# you cannot go from a char const to a string const, and chars are a special kind of int.
In Delphi you cannot go from a string to a char. Read the rest of this entry »
Posted in .NET, ASCII, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Development, Encoding, Software Development, Unicode | Leave a Comment »
Posted by jpluimers on 2013/01/03
You’d hope that a method like Wordify with the signature below would be simple right?
public static string Wordify(string pascalCaseString)
Not so. Read the rest of this entry »
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | 1 Comment »
Posted by jpluimers on 2013/01/01
Every time I use regular expressions (or post about them), it makes me think about the classic RegEx post by Jeff Atwood: to compile or not to compile.
BTW: Happy 2013!
–jeroen
Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, RegEx, Software Development | Leave a Comment »