Tag: .net ¦ Atom ¦ RSS

Implicit conversions in C#

Yesterday I came across an interesting article: What's the opposite of Nullable. While the solution for Non-Nullability is interesting, the reason i'm blogging this is because the article also used a C# feature which i didn't know of: implicit conversions.

And guess what? Today I had a situation where I could use these implicit conversions. My app reads data from a CSV-file, so all the input are just strings. Until now that was just fine. However, at one part of my code I had to process one of the fields which has a fixed format. Say a field is a phonenumber and i need the country-prefix. So I created a PhoneNumber-class like this:

public class PhoneNumber
  private readonly string _number;

  public PhoneNumber(string number)
      if (!new Regex(PHONE_NUMBER_REGEX).IsMatch(number))
          throw new ArgumentException("Invalid phone number", "number");
      _number = number;

  public string Prefix
    get { return GetPrefixFromNumber(...); }

Now it is possible to create a (helper-)method in another class to get the prefix like this (this is just a simple example):

public …


Gisteren mocht ik voor het werk een dagje van de Microsoft Techdays bijwonen. Het was de eerste keer dat ik naar een Microsoft-event ging en had me eerlijk gezegd aan veel show en weinig inhoud verwacht. In sterk contrast tot JavaPolis Devoxx, waar er veel inhoud en weinig show is. Achteraf bekeken viel dit eigenlijk enorm goed mee. Enkel de keynote ging er wat over. Een Developer Evangelist of Regional Director moet echt niet als één of andere superster worden aangekondigd met loeiharde muziek en lichtshow, maar dat is mijn mening natuurlijk.

Na de keynote heb ik de sessie over C# 4.0 gevolgd en dat was erg interessant. C# 4.0 belooft weer een versie te worden om naar uit te kijken. Eén van de nieuwe features is het dynamic keyword. Dit zorgt ervoor dat je methodes op het object kan oproepen waarbij de compiler niet checked of deze effectief bestaan. De check wordt pas 'at runtime' gedaan. Dit is erg handig om te integreren met andere talen zoals …

ASP.NET MVC 1.0 Quickly

Today I was pretty surprised when going through my feeds to read that a friend of mine, Maarten Balliauw, has a written a book. The title of the book is ASP.NET MVC 1.0 Quickly:

It’s been quite a job, but there it is: Packt just announced my very first book on their site. It is titled “ASP.NET MVC 1.0 Quickly”, covering all aspects ASP.NET MVC offers in a to-the-point manner with hands-on examples. The book walks through the main concepts of the MVC framework to help existing ASP.NET developers to move on to a higher level. It includes clear instructions and lots of code examples. It takes a simple approach, thereby allowing you to work with all facets of web application development. Some keywords: Model-view-controller, ASP.NET MVC architecture and components, unit testing, mocking, AJAX using MS Ajax and jQuery, reference application and resources.

I always thought, and still think, that writing a book is a massive amount of work. Therefore i really …