Unless you have a VERY good reason, rethrow your exception.

I see it a lot, people write a function, they catch a possible exception and throw one of their own OmgSomethingHorribleHappenedException(); Check this simplefied example: private static void Main() { try { var result = (new Api()).Find(“foo”); Process(result); } catch (Exception e) { Console.WriteLine(e.Message + Environment.NewLine + e.StackTrace); Console.Read(); } } And the Api.Find(string toFind) […]

Deserializing xml: Data at the root level is invalid. Line 1, position 1

A couple of days ago a colleague of mine encountered a problem where he had some objects that define a configuration needed to be stored in the database. He would serialize the data with the following code: public static class XmlSerializerHelper { public static string SerializeXml<TObject>(this TObject objectToSerialize) { using (var memoryStream = new MemoryStream()) […]

Check if your LinkedIn password appears in the leaked file.

Get the file from the internet. Change the line that points to the file. Run the app, type your password and be happy or sad. using System; using System.IO; using System.IO.MemoryMappedFiles; using System.Security.Cryptography; using System.Text; namespace LinkedInFileSearcher { internal static class Program { private const string PathToLinkedInFile = @”c:\combo_not.txt”; private static void Main() { ConsoleKeyInfo […]