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.
In C#, you can use the object/collection initialization syntax like this:
If you’re reading this post, you probably know about F#’s Units of Measure already, it’s very useful when working with real-world units and adds extra safety to code that needs to work with and convert from one unit to another.
In C#, you define an empty class, struct, or interface like this:
So how do you define an empty type in F#?
Well, whenever you define a new class in F#, the compiler infers the class and end…
There’re a number of built-in literal types in F#, and one of the cool things you can do is to get the byte or byte array representation of a char or string using the ‘B’ suffix, the result is the same as Encoding.ASCII.GetBytes:
In C#, when you define an event in your class, e.g.:
If your have a type that represents a collection of values, adding a custom indexer gives you a natural way to index directly into the object using the .[ ] operator.
I needed to find out which process is listening on a port the other day and a quick search on SO showed me the way and all you need is to run:
netstat –aon | find /i “listening”
To get the default value of a type, you’ve probably used the default keyword in .Net already:
1: var defaultInt = default(int); // 0
2: var defaultObj =…
By default the GAC folder in Windows is located at %windir%\assembly, you can find all the registered DLLs in that folder. Whilst you can open it in windows explorer and view it like any other folder, it is a somewhat special and allows you to have different versions of the same DLL…