Mattdef:
Why this code is 2 times longer in D then C# ?
By "code longer" I assume you mean its run time. The answers could be multiple, like you using DMD instead of LDC2/GDC, or you using the wrong compilation switches, or perhaps because Microsoft has poured on the Dotnet ten thousands times more money compared to DMD. Or perhaps your code is just not good enough for D, who knows? Why don't you profile the code and look at the machine language for possible problems?
I don't have time now to do the optimization for you now, sorry. Bye, bearophile