Better String Input Handling

I’ve been relatively quiet on my blog lately in part because of all the work on ASP.NET MVC. However, the ASP.NET team is a relatively small team so we often are required to work on multiple features at the same time. So part of the reason I’ve been so busy is that while we were wrapping up ASP.NET MVC, I was also busy working on a core .NET Framework feature we plan to get into the next version (it was a feature that originated with our team, but we realized it belongs in the BCL).

The goal of the feature is to help deal with the very common task of handling string input. In many cases, the point is to convert the input into another type, such as an int or float. However, how do you deal with the fact that the string might not be convertible to the other type.

We realized we needed a type to handle this situation. A type that would represent the situation after the user has submitted input, but before you attempt the conversion. At this point, you have a string or another type.

clip_image004_thumb

For more details on the StringOr<T> Community Technology Preview (CTP), please see details on lead developer Eilon Lipton's Blog (he’s a big fan of cats as you can see). He provides source code and unit tests for download. As always, please do provide feedback as your feedback is extremely important in helping shape this nascent technology.

Related Blog Posts

Tags: ,

What others have said

Requesting Gravatar... Burak Mar 31, 2009 9:05 PM
# re: Better String Input Handling
Is it a feature of .NET April 1 Preview? :P
Requesting Gravatar... grega g Mar 31, 2009 9:37 PM
# re: Better String Input Handling
i hope that's an April's fool joke.
Requesting Gravatar... Bryan Mar 31, 2009 10:09 PM
# re: Better String Input Handling
I really really hate this day. Thanks for wasting my time.
Requesting Gravatar... Patrik Mar 31, 2009 10:24 PM
# re: Better String Input Handling
First I thought "WTF", but then I realized that it is April 1:st today. :-)
Requesting Gravatar... tawani Mar 31, 2009 10:35 PM
# re: Better String Input Handling
This is BS. This is the test you want to perform:

StringOr<int> userInput = "abc123";
Assert.AreEqual(123, userInput.OtherValue);
Requesting Gravatar... Jack Mar 31, 2009 10:36 PM
# re: Better String Input Handling
I liked this story than the 'Warner Bros acquires the Pirate Bay'. It's our geek type joke, a good one. Thanks Phil!
Requesting Gravatar... Michael D. Hall Mar 31, 2009 10:36 PM
# re: Better String Input Handling
Well played sir, well played.
Requesting Gravatar... Neil barnwell Mar 31, 2009 10:58 PM
# re: Better String Input Handling
It seems a bunch of MS guys have teamed up to play this trick together, hoping that we'd fall for it. This is at least the 3rd post today about StringOr<T> I've seen.

Thing is, joke or not, I bet there are real StringOr<T> implementations out there in the world...
Requesting Gravatar... alexandrul.ct Apr 01, 2009 12:12 AM
# re: Better String Input Handling
Fine joke and nice ideea.
Requesting Gravatar... Darren Kopp Apr 01, 2009 12:22 AM
# re: Better String Input Handling
should have just said in v4 strings are mutable and everyone's jaws would have dropped.
Requesting Gravatar... Walter Apr 01, 2009 12:43 AM
# re: Better String Input Handling
I checked the blog just to see what the April Fools joke would be today. It was a little over my head, but it seems the fan base liked it!
Requesting Gravatar... Chris S Apr 01, 2009 1:41 AM
# re: Better String Input Handling
April Tool'd
Requesting Gravatar... haacked Apr 01, 2009 2:03 AM
# re: Better String Input Handling
StringOr<WTF>
Requesting Gravatar... Raguraman Apr 01, 2009 2:04 AM
# re: Better String Input Handling
Wow !!! What a Plan !!!

You all got me.
Requesting Gravatar... Andy Apr 01, 2009 4:18 AM
# re: Better String Input Handling
Oh my god, you can even joke with these things...

A real NERD joke.
Requesting Gravatar... Jack Apr 01, 2009 10:13 AM
# re: Better String Input Handling
It's April 2nd now, can you tell me is it a joke or not?
Requesting Gravatar... RussellH Apr 01, 2009 1:22 PM
# re: Better String Input Handling
Was this the answer to my question about exception handling in the Nerd Dinner app? It was an April Fools joke?
Requesting Gravatar... C.T. Apr 02, 2009 9:17 AM
# re: Better String Input Handling
i felt this tech is some difficult to understand for me before i read the comments.
Requesting Gravatar... rpgkaiser Apr 06, 2009 4:21 AM
# When i would make a component driven MVC site?
Hello! MVC is a great product (or tech, whatever), but is annoying the kind of interaction we most forced to deal with. I mean the mass use of HTML helper methods instead of the extremely most pleasure component based approach. I know this is a remarkable work to do in order to enable this design pattern in MVC, but in my opinion, while this limitation exist, MVC will be a downgrade compared to WebForm, in term of design capabilities and useability.

What do you have to say?

(will show your gravatar)
Please add 5 and 5 and type the answer here: