Tips

Resharper – Using custom patterns to catch subtle bugs with OfType<T>

One of the pitfalls with LINQ which I have fallen into on multiple occasions is around the use of the OfType<T> extension method with dictionaries. Either through carelessness or changes to the underlying variable (a class property being changed from list to dictionary for instance) I have ended up using OfType<…> on a dictionary which …

Resharper – Using custom patterns to catch subtle bugs with OfType<T> Read More »

F# equivalent of C#’s Object Initialization syntax

In C#, you can use the object/collection initialization syntax like this: The F# equivalent of object initialization is done like this: As for collection initialization, you have a far more diverse range of tools available to you, for example: You can also create slices of an existing array: You can even add your own multi-dimensional …

F# equivalent of C#’s Object Initialization syntax Read More »

.Net Tips – use [field:NonSerialized] to stop serializing your event handlers

In C#, when you define an event in your class, e.g.: the event handlers will be serialized along with other properties, etc. This is because under the hood, the compiler translates your event into the following, as can be seen through JetBrain’s dotPeek decompiler: Since the generated EventHandler is not marked with the [NonSerialized] attribute …

.Net Tips – use [field:NonSerialized] to stop serializing your event handlers Read More »

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close