Posterous theme by Cory Watilo

Filed under: VB.NET

New version of Typemock Isolator is out

Programming Visual Basic applications?


Typemock have released a new version of their unit testing tool, Typemock Isolator 5.2.
This version includes a new friendly VB.NET API which makes Isolator the best Isolation tool for unit testing A Visual Basic (VB) .NET application.


Isolator now allows unit testing in VB or C# for many ‘hard to test’ technologies such as SharePoint, ASP.NET MVC, partial support for Silverlight, WPF, LINQ, WF, Entity Framework, WCF unit testing and more.


Note that the first 25 bloggers who blog this text in their blog and tell us about it, will get a Free Full Isolator license (C#, VB, and Sharepoint included - worth $139 !!!). If you post this in a VB.NET dedicated blog, you'll get a license automatically (even if more than 25 submit) during the first week of this announcement.


Go ahead, click the following link for more information on how to get your free license.

The difference between the + and & operators in VB.NET

It’s quote common to see VB.NET code where the author does not know about the distinction between the two concatenation operators. While the code probably compiles and executes just fine one of the operators leaves you vulnerable to unexpected errors if, for example changes are made to the code.


Take a look at the following code snippet for a second and see if you can spot why the second concatenation will throw and exception.


Dim value As Double = 10DDim correct As String = _   "The value is " & value & ". Pretty cool, huh?"Dim incorrect As String = _   "The value is " + value + ". Pretty cool, huh?"

The exception which is thrown is “Conversion from string "The value is " to type 'Double' is not valid.”. Huh? We’re concatenating into a string aren’t we? So why do we get an InvalidCastException that tells us it wasn’t able to cast to a double?


The short version is that in VB.NET the & is known as the string concatenation operator, thus expects both the left hand and right hand side of the operator to be strings and if they’re not it will try to perform a cast to a string before performing the concatenation.


The + operator tries to add two values together and its behaviour on what to do, if mixed data types are involved, is controlled by far more complex logic (see the link below for the full story) and environmental variables such as the Option Strict settings.


& Operator

http://msdn.microsoft.com/en-us/library/wfx50zyk.aspx


+ Operator

http://msdn.microsoft.com/en-us/library/9c5t70w2.aspx