Convert.ToInt32 versus TryParse

There are two way of converting strings to numerical values in .NET. The first one, supported since the first version of the platform, is the use of System.Convert class. It has methods like ToInt32, ToChar, ToDouble, ToDataTime, ToDecimal, etc. Here is an example of converting string “123” to numerical value 123. string text = “123”;…

CategoriesC#

Visual Studio Gallery

Microsoft launched yesterday Visual Studio Gallery, a site hosting Visual Studio extensions. Currently, there are over 350 such extension, free or per charge. The extension include macros, add-ins, packages, project templates. A good thing is that anybody can contribute with content to this gallery. There are some very good extensions available in the gallery. You…

Microsoft DreamSpark

Recently Microsoft launched a program called DreamSpark addressed to students from all over the world (though currently the program is available only in 10 countries) that allows them to used for free software created by Microsoft. This includes: development tools: Visual Studio 2005 Professional Edition Visual Studio 2008 Professional Edition XNA Game Studio 2.0, 12-month…

Microsoft Office Binary File Formats

Last week Microsoft published the 97- 2007 binary file formats for Word, Excel, PowerPoint and Drawing. They can be downloaded from here. Joel Spolsky has a very good article on the subject. A normal programmer would conclude that Office’s binary file formats: are deliberately obfuscated are the product of a demented Borg mind were created…

Forward Declaration for a Class from a Namespace

Suppose you have a class declare in a namespace, like this: #pragma once namespace Test { class foo { public: foo(void); ~foo(void); }; }; #include “foo.h” namespace Test { foo::foo(void) { } foo::~foo(void) { } }; And you want to use that foo class in a another class, with a forward declaration: #pragma once class…

C# ListBox with Variable Height Items

Suppose you need a ListBox that has to display items with the text spread across multiple lines. With the default implementation that would look like this: The CR LF characters are displayed as squares and the item has only one line of text. To make the list box items have variable height depending on the…

STL string utils

STL’s std::string doesn’t have methods for transforming the string to upper or lower case or for trimming (as other string implementations, such as CString, have). I’ve noticed that many people don’t know how to implement such functions, so I’ll show you here how to do that. class stringutils { public: static void make_upper(std::string& text) {…

End of 2007

I started this blog at the beginning of 2007 and until now I had more than 10,000 unique visits, which is pretty good, I believe. I wrote here about LINQ, C#, C++, Visual Studio, events and others. I hope they served the readers well, and I’ll try to write more during the next year. This…

Sphere inside out

I was reading a book about Mobius band and I read about turning a sphere inside out, without making a hole in it. Though this appears impossible, it is actual possible when you follow some rules. Looking over the web I found a very good movie showing and explaining how it’s done. For those interested in…

1st European Silverlight Challenge

INETA Europe in collaboration with Microsoft organized a competition called European Silverlight Challenge, organized on country based, with the winners from each country participating in the European final. It is based on the development of a web component or application using Silverlight for its user interface and with the only condition that it to be…