Archive for 'Languages' Category

Next Page »

Story of a stupid bug, difference between struct and class

24 June 2008

I’ve incurred in a very stupid bug this afternoon, I run test on a new version of a component and I see that a lot of exceptions are raised about violating unique constraint of a simple strongly typed dataset I use to log information in database.
After a brief look at the code I found that [...]

A generic IComparer that works with reflection

2 July 2007

Today I was speaking with a colleague about creating a generic IComparer<T> that is able to compare two object based on a property discovered through reflection. Such object will be very useful to sort or find object inside collection of objects when you work with a domain model. In a domain we usually have a [...]

C# anonymous delegates and template pattern

5 June 2007

Yesterday I blogged on a slightly modified version of Ayende code posted here, this makes me reflect on template pattern of the GOF. Template pattern is one of the most useful pattern, and is used when you have a common block of code that is to be repeated in may part with a little customization. [...]

The old plain C language

28 May 2007

A friend of mine is taking a basic course in computer programming, and actually he is studying the basic of C language. Yesterday he told me that he must do a very simple exercise that will print on screen a triangle like thisXXXXXXXXXXXXXXXXXXXXXXXXXXXAnd so on. He asked me if I could review his solution before [...]

Difference between C# and VB, simple add

26 May 2007

Sometimes differences between C# and VB could be subtle, for example consider these very simple two snippets of code, what they will print?

   Sub Main()      Console.WriteLine(“Result is “ + Sum(Integer.MaxValue, 1))   End Sub    Public Function Sum(ByVal a As Integer, ByVal b As Integer)      Return a + b   End Function   static void Main(string[] args) {      Console.WriteLine(“Result is “ + Sum(Int32.MaxValue, 1));   }    public static Int32 Sum(Int32 a, Int32 b) {      return a + b;   }

The first snipped written in VB throws a System.OverflowException, because the result of the operation cannot be stored into an integer value. The behavior of C# can be more surprising because it print [...]


Next Page »