Greg Beech's Website

Browse by Tags

  • Disposing and finalizing partially constructed objects

    On MSDN forums there was a question about whether class constructors should be permitted to do a lot of work or not : I have a dilemma and a dispute with some colleagues: should the constructor of a C# class do a lot or the minimum and latter in a method call put a lot of logic? I am coming from a C++ background and there it is better to do just simple data initialization in the constructor, throwing...
  • Implementing and using the IDisposable interface

    You might be wondering why I'm writing about the IDisposable interface a full five years after the .NET framework was released, when you'd think that everybody knows everything about disposing objects anyway. But there are many people who are new to the framework and need some guidance, and many people who have been working with it for some time but still seem not to understand the significance...
  • Static vs instance method performance

    I'm sick of the static vs instance methods argument based on performance. Performance has nothing to do with it. You should make your methods either static or instance depending on the way the method is used and what is more intuitive to the user of the class. Even Microsoft are guilty of pushing the performance agenda with an FxCop rule which moans about the 'this' pointer not being used...
  • Implementing object equality in .NET

    At first glance it seems simple to implement object equality in .NET, just override the Equals method inherited from System.Object, but in reality there actually are a lot of potential problems. You need to consider comparing null objects, and also the string representation, hash code and immutability of the object otherwise your application might behave oddly in specific circumstances. Here's...
Copyright (C) Greg Beech. All rights reserved.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems