Tag Archives: C#

Mocking “this”

Let’s assume we have a simple service that is also using an inner service, providing a few operations as follows: public interface IService {     string A();     string B();     string C(); } public class Service : IService {     private readonly IInnerService innerService;     public Service(IInnerService innerService)     {         this.innerService = innerService;     }     public string A()     {         return “A”;     }     public string B()     {         return b(); … Continue reading

Posted in .NET, C# | Tagged , , , | Leave a comment

Invariant string interpolation

I’m sure you like C# string interpolation support ($”{…}”): var start = DateTime.Now; var end = start.AddDays(7); string weekIntervalText = $”{start}-{end}”; But you also know that this uses the current thread’s culture to format the string, so you think “Oh, … Continue reading

Posted in C# | Tagged , , , , | Leave a comment

Auto-disposing? Empty using syntax?

What do you think? Should this code auto-dispose the X object instance created but not used? If you test it, you’ll see it does not: public class X : IDisposable { … } static void Main(string[] args) {     … Continue reading

Posted in C# | Tagged , , , | Leave a comment


When you, a Microsoft technology-oriented developer, write software today you have to select the target platforms you would like to support. The platforms are then used to select the tools, technologies, and programming languages you can use for coding the different layers of … Continue reading

Posted in .NET, Architecture, C#, Development, JavaScript, Unity | Tagged , , , , | Leave a comment

Non-game 3D apps in Unity

HoloLens (and more generally, Windows Holographic) is around the corner and will transform the way people interact with devices and their expectancies from them. Holograms and 3D gestures are the new user interface elements you need to consider when you develop … Continue reading

Posted in HoloLens, Unity, UWP | Tagged , , , | 1 Comment

A single line after if shouldn’t require {braces}

I saw many C# style guidelines (or even enterprise standards) requiring that the code statements within of if (or else, or else if) clause should always require braces ({, }), even when there is a single statement to run. I feel … Continue reading

Posted in .NET, C# | Tagged , , , , | Leave a comment

Component development decision: low level or high level techologies?

If you want to develop software components targeting other developers and their projects, you should carefully decide what technologies would you develop for and support: Low level technologies, e.g. C++ or JavaScript (HTML5); High level technologies, e.g. .NET (WPF/Windows Forms/ASP .NET) or … Continue reading

Posted in Architecture | Tagged , , , , | Leave a comment

What programming language should I learn? (if I were a student)

What programming language should one learn or focus on if he or she was a computer sciences student and intended to work as a software developer? This question was a tough one in the past too, but today it is especially difficult because there are even … Continue reading

Posted in Development, Miscellaneous | Tagged , , , , , , , , , , , | Leave a comment

Raising custom events

How do you define and raise custom events in C#? public event EventHandler<TEventArgs> MyEvent; protected virtual OnMyEvent(TEventArgs e) { if (MyEvent != null) MyEvent(this, e); } This is fine, but now in a multi-threading environment, where things get nasty: suppose … Continue reading

Posted in .NET, C# | Tagged , , | Leave a comment

To var or not to var

Do you think it’s better to use var keyword of C# when you declare variables, or always set them up using their types? I personally prefer the var shortcut but only when the name of the variable identifies its type, especially … Continue reading

Posted in .NET, C# | Tagged , , | Leave a comment