Why C# is not allowing non-member functions like C++

See this blog posting: http://blogs.msdn.com/ericlippert/archive/2009/06/22/why-doesn-t-c-implement-top-level-methods.aspx (…) I am asked “why doesn’t C# implement feature X?” all the time. The answer is always the same: because no one ever designed, specified, implemented, tested, documented and shipped that feature. All six of those things are necessary to make a feature happen. All of them cost huge amounts … Read more

Resolving MSB3247 – Found conflicts between different versions of the same dependent assembly

Change the “MSBuild project build output verbosity” to “Detailed” or above. To do this, follow these steps: Bring up the Options dialog (Tools -> Options…). In the left-hand tree, select the Projects and Solutions node, and then select Build and Run. Note: if this node doesn’t show up, make sure that the checkbox at the … Read more

Static Generic Class as Dictionary

I like using generic types this way. In particular, I often have private nested generic classes for precisely this purpose. The main thing I like about it is that it’s hard not to get the initialization right this way (in terms of thread safety), given the way type initialization works. The only problem is what … Read more

How to call .NET methods from Excel VBA?

Here is a canonical answer on the 3 main methods to call .Net from Excel (or VBA). All three ways work in .Net 4.0. 1. XLLs The 3rd party vendor Add-In Express offer XLL functionality, however its free and easy to use Excel-DNA the author is here https://stackoverflow.com/users/44264 Here is an extract from the Excel-DNA … Read more

Stack capacity in C#

The default stack size for a .NET application is 1 MB (default is 256 KB for 32-bit ASP.NET apps and 512 KB for 64-bit ASP.NET apps), but you can change that. For the application you can change the default size by modifying the PE header of the executable. For threads you create, you can use … Read more

C# ‘is’ operator performance

Using is can hurt performance if, once you check the type, you cast to that type. is actually casts the object to the type you are checking so any subsequent casting is redundant. If you are going to cast anyway, here is a better approach: ISpecialType t = obj as ISpecialType; if (t != null) … Read more

What are the roots?

If you think of the objects in memory as a tree, the “roots” would be the root nodes – every object immediately accessible by your program. Person p = new Person(); p.car = new Car(RED); p.car.engine = new Engine(); p.car.horn = new AnnoyingHorn(); There are four objects; a person, a red car, its engine and … Read more