C# Coding conventions

These coding conventions were originally written by my colleagues Filip Kassovic and Michal Třešňák in ST-Software. I have only made slight updates and published it on my blog. Do not use “var” keyword when not necessary var response = SomeClass.SomeMethod(input); Reason we don’t see the type of “response” “Find Usages” or “Find all references” doesn’t find …

C# – How to find overlap of datetime intervals

I needed to count the overlap of the datetime intervals. After some coding I’ve refactored the code to static class and uploaded to Github, so that others can use it too. It might save you some time 🙂 There are currently two methods. One to get the interval overlap and the other to count the interval …

How to speed-up generating PDFs via TMS Flexcel

In my current project we needed to generate lot of PDFs from the same excel template.  For this we use TMS Flexcel library. It is a simple library for generating Excel or PDF files in .NET. It loads a xls template from filesystem, populates it with data and that’s it. Quite easy. But generating tons of files in a …

StaticExtension not found

I have encountered funny bug/feature when I was writting first xaml file in my new project. I used the StaticExtension the way I was used to… and for some obscure reason it did not work. This is what I typed: <Someclass SomeProperty=”{x:Static SomeOtherClass:SomeStaticProperty}”/> But Visual Studio did not like it and complained that Static is …

How to get text value from HtmlTextWriter in C#

HtmlTextWriter is very nice tool to generate HTML in C#, but it lack ability to get generated HTML as a string. Here is a simple solution: HTmlTextWriter uses internally StringWriter which uses StringBuilder. So you first create StringBuilder and StringWriter, pass them to HtmlTextWriter and when you are done you simply call ToString() on the …