September 9, 2008
Sometimes, you need a string of a certain length, filled with a certain character, usually whitespace. I use it quite a bit, to replace a certain piece of text with an equal amount of whitespaces. But if all you have is the fill character and a desired length, how do you get a proper string? In a lot of languages, you would have to use e.g. a for-loop to loop X number of times and append to a resulting string, but not with the .NET framework. The String class comes with a constructor which allows you to accomplish the above very easily. Here is an example:
string whitespace = new String(' ', 10);
Or perhaps you need something that will look like a password?
string password = new String('*', 8);
Just another one of those small things that makes the .NET framework such a pleasure to work with.
September 2, 2008
One of my biggest concerns when starting to build .NET applications, was the lack of framework installations around the world. Microsoft were promising to push it through Windows Update and Windows XP SP2, but that part didn’t really work for them until Windows Vista was released, which included both .NET 2.0 and .NET 3.0. However, since there are still quite a few Windows XP machines out there, and even worse, Windows 98 and Windows Me machines, you really can’t expect everyone to have the required version of the .NET framework installed.
One alternative is to use an expensive product which will bundle your application together with at least parts of the framework, but it usually IS very expensive, and it will result in a pretty big file, which you have to distribute. That might be good enough in your scenario, but for me, I wanted to be able to distribute only my own files.
If you’re using a very fancy installer, it might support the installation of the .NET framework from the beginning, but personally, I use the very neat and very lightweight Inno Setup. It’s free, easy to use, it supports command line operations, has a lot of options and a scripting language for you to extend your setups with, and it produces fast and very well compressed EXE setup files. I really do recommend it.
Since Inno Setup supports scripting, this guy Andrew made a very cool extension, which will automatically download and install the .NET framework to the clients computer, if it’s not already present. You can read more about it here and find the mentioned script here. I think that it’s a very elegant solution to a problem that a lot of .NET developers will face, while we still wait for the framework to be present on every computer in the world
September 1, 2008
Welcome to the blog here at net-tutorials.com. We hope to provide you with some insightful posts in the near future. My initial thoughts are to use this space for tips & tricks, news and just pretty much everything .NET related I can come up with. If you wish to contribute, please leave a comment