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,862 other subscribers

Archive for the ‘C# 5.0’ Category

c# – What are your thoughts on Raven DB? – Stack Overflow

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 »

.NET/C#: Class declarations initially set are indeed different than setting them in a constructor (via: Stack Overflow)

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 »

sql server – How do I programmatically set the connection string for Entity-Framework Code-First? – Stack Overflow

Posted by jpluimers on 2013/01/15

For my link archive:

sql server – How do I programmatically set the connection string for Entity-Framework Code-First? – Stack Overflow.

use the EntityConnectionStringBuilder see this How to: Build an EntityConnection Connection String.

–jeroen

Posted in .NET, .NET ORM, C#, C# 4.0, C# 5.0, Development, EF Entity Framework, Software Development | Leave a Comment »

Converting Visual Studio 2003 WinForms to Visual Studio 2005/2008/2010/2012 partial classes (via: Duncan Smart’s Weblog)

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 »

.NET/C#: what is the meaning of “Comparing two IEnumerables for equality”?

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 »

Delphi and C# compiler oddities

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 »

Wordify: .NET/C# – Convert enums to human readable values – Stack Overflow

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 »

.NET regular expressions classic: to compile or not to compile?

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 »

.NET/C#: use Assembly.GetName() if you to access internal/private information from Assembly

Posted by jpluimers on 2012/12/26

There is a lot of information in Assembly that is either internal or private. Luckily you van get an AssemblyName instance through Assembly.GetName() or Assembly.GetName(Boolean) which has quite a few public members that get initialized while calling the internal AssemblyName.Init method.

This is the member mapping of AssemblyName members to Assembly members:

AssemblyName member Assembly member
Name GetSimpleName() *internal
GetPublicKey() GetPublicKey() *internal
GetPublicKeyToken() null
Version GetVersion() *internal
contains the AssemblyVersionAttribute of the assembly
CultureInfo GetLocale() *internal
HashAlgorithm GetHashAlgorithm() *private
VersionCompatibility AssemblyVersionCompatibility.SameMachine
CodeBase GetCodeBase(Bool) *internal
Flags GetFlags() | AssemblyNameFlags.PublicKey
KeyPair null
ProcessorArchitecture complex set of calls

–jeroen

via: Assembly.GetName Method (Boolean) (System.Reflection).

Posted in .NET, .NET 3.5, .NET 4.5, ASP.NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »

.NET/C# – How to create a file and its parent directories in one method call? (via: Stack Overflow)

Posted by jpluimers on 2012/12/18

Ever since .NET 1 there has been no built-in way to create a file including all its parent directories.

Hence small FileHelper class far below.

The fundament of the class is this CreateUnderlyingDirectory method, that uses System.IO.Path.GetDirectoryName to obtain the parent directory of a path, and then System.IO.Directory.CreateDirectory to create it (and any parent directories) if needed.

        public static void CreateUnderlyingDirectory(string path)
        {
            string directoryPath = Path.GetDirectoryName(path);
            Directory.CreateDirectory(directoryPath); // NOP if it exists, will create all parent directories if not
        }

A few helper methods get you a StreamWriter either empty/appended, or always empty 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 »