C# Frequently Asked QuestionsThe C# team posts answers to common questionsHow do I play default Windows sounds- March 28, 2006 Sometimes, you might want to make your application a bit more audible. If you are using .NET 2.0, you can utilize the new System.Media namespace and its SystemSound and SystemSounds classes. The SystemSounds class contains five static properties that you can use to retrieve instances of the SystemSound class. This class in turn contains the Play() method, which you can use to play the wave file associated with the sound in Windows Control Panel. Note that the user can also disable all sounds...http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562557.aspx How can I easily log a message to a file for debugging purposes- March 28, 2006 Often, you need a way to monitor your applications once they are running on the server or even at the customer site -- away from your Visual Studio debugger. In those situations, it is often helpful to have a simple routine that you can use to log messages to a text file for later analysis. Heres a simple routine that has helped me a lot for example when writing server applications without an user interface:using System.IO; public string GetTempPath() string path =...http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562555.aspx How can I speed up hashtable lookups with struct object as keys- March 21, 2006 When you have struct objects as the key in a hashtable, the lookup operation of the hashtable performs miserably. This can be attributes to the GetHashCode() function which is used internally to do the lookup. If a struct contains only simple value types (int, short, etc.), the algorithm which computes the GetHashCode creates hashes which fall into mostly the same bucket. Example, lets say, the hashtable creates 10 buckets. Then, most probably, all the keys are being put into the same...http://blogs.msdn.com/csharpfaq/archive/2006/03/20/556192.aspx |