STM.NET

Microsoft has made available a first beta version of an experimental version of .NET 4.0, called .NET Framework 4.0 Beta 1 Enabled for Software Transactional Memory v1.0. Since that is quite a long name, the short one is STM.NET. This is a special version of .NET 4.0 that enables software transactional memory for C#. It…

.NET out string[] to Automation SAFEARRAY**

.NET allows you to expose components as COM and consume them from unmanaged code. There are many references on how to this (and you can only start with MSDN), and I will not talk about that part. What I want to explain here is something different. Suppose you have this interface:

Method GetUsers() returns…

More About Code Contracts

In a recent post I wrote about Code Contracts in .NET. Now you can find a more detailed article on this topic at sharparena.com. In this article I’m providing more information and examples on: pre-conditions post-conditions object invariants asserts and assumptions quantifiers In additions, you should check the official user documentation, which can be found…

Code Contracts in Visual Studio 2010

Visual Studio 2010 has support for code contracts that allow to express pre-, post-conditions and invariants to your .NET code. Let’ say you want to create a function to return a random value in a range. This could look like it:

However, at a rough analysis one can find two problems: Second call to…

BigInteger Is Back

One of the new features in .NET 4.0 is the BigInteger class. This was suppose to be part of 3.5 framework, but after the CTP it was gone. Now it’s back. This big integer is a really large integer representation. However, I was not able to find the precision documented anywhere. The class is available…

Optional and Named Parameters in C# 4.0

So far, C#, unlike C++, did not support optional arguments. For instance, suppose you need a function to print log a message, that can add a new line or not after writing the message. Most of the times you want a new line, so you don’t want to specify that for most of the calls….

Type inference in C++

The new C++0x standard provides support for type inference. The auto keyword that was doing nothing in C++ was given a new meaning: a placeholder for a type inferred by the compiler. For those familiar with C#’s var keyword, this is basically the same. Here is a comparison between auto in C++ and var in…

Evaluating Expressions – Part 2: Parse the Expression

In my previous post I have provided some background theory for evaluating expressions with abstract syntax trees. As I was mentioning, the first step towards this goal is to parse the expression, make sure it is correct syntactically. This is what I’ll show you in this post. Having the grammar defined, we’ll make one function…

50917 errors

This is the record number of error I ever got in a project: 50917. After compiling that VC# project (with T4), Visual Studio 2008 was a little bit overwhelmed. It started to report out of memory errors and failed to build after fixing the error. A restart was, of course, the cure.

New Things in C# 4.0

A few days ago Anders Hejlsberg delivered a presentation about the Future of C# at the Professional Developers Conveference 2008. He focused on the new things that will be available in C# 4.0: dynamic typed objects optional and named parameters improved COM interoperability co- and contra-variance The recording of the presentation is available on Channel9…