Most unintuitive behaviour in the .Net framework?

Posted by BlueRaja on Stack Overflow See other posts from Stack Overflow or by BlueRaja
Published on 2010-03-29T23:12:32Z Indexed on 2010/03/29 23:23 UTC
Read the original article Hit count: 368

Filed under:
|
|

Intended behavior is often another phrase for bug-which-we-knew-about-when-we-wrote-it, but-we-wrote-it-anyways. Because it was "intended" (or perhaps it is now too late or too difficult), many of these extremely-unintuitive bugs never get fixed.

For instance, consider the following code (C#):

TextInfo textInfo = Thread.CurrentThread.CurrentCulture.TextInfo;

textInfo.ToTitleCase("hello world!"); //Returns "Hello World!"
textInfo.ToTitleCase("hElLo WoRld!"); //Returns "Hello World!"
textInfo.ToTitleCase("Hello World!"); //Returns "Hello World!"

What would you expect textInfo.ToTitleCase("HELLO WORLD!"); to return? In fact, it returns "HELLO WORLD!". This was well-documented "intended behavior," but, in my eyes, is extremely unintuitive, and therefore a bug.

What is some other unintuitive behavior like this in this in the .Net framework? Bonus points if you can provide a fix that does not break backwards-compatibility.


Remember! Always keep these two simple rules in mind when designing an API (or anything else):
Make the common case the default, and Keep It Simple, Stupid!

© Stack Overflow or respective owner

Related posts about .NET

Related posts about fun