if statement – short circuit evaluation vs readability in C++

Published on

Sometimes, an if statement can be rather complicated or long, so for the sake of readability it is better to extract complicated calls before the if. e.g. this: if (SomeComplicatedFunctionCall() || OtherComplicatedFunctionCall()) { // do stuff} into this bool b1 = SomeComplicatedFunctionCall(); bool b2 = OtherComplicatedFunctionCall(); if (b1 || b2) { //do stuff } (provided … Continue reading if statement – short circuit evaluation vs readability in C++

how to make DispatcherTimer events smoother in WPF?

Published on

Set a priority. The default is Background, that might explain the stuttering you see. I think Render is the level you want but do experiment. DispatcherTimer timer = new DispatcherTimer(DispatcherPriority.Render); If that isn’t smooth enough you could try setting it up as an Animation.

C# List definition, parentheses vs curly braces

Published on

The use of curly braces { } is called a collection initializer. For types that implement IEnumerablethe Add method would be invoked normally, on your behalf: List<string> myList2 = new List<string>() { “one”, “two”, “three” }; Empty collection initializers are allowed: List<string> myList2 = new List<string>() { }; And, when implementing an initializer, you may … Continue reading C# List definition, parentheses vs curly braces

How many bytes of memory will be allocated in stack and in heap if we use a 64-bit processor?

Published on

answer of 44 bytes is probably a confusion referring to an array of 32 bit architecture. In. Net (32 bit): Every object contains 4 bytes for synchronization (lock (obj)). Every object contains 4 bytes of its type token. Every array contains 4 bytes of its length. The pointer is 8 bytes as you said. This … Continue reading How many bytes of memory will be allocated in stack and in heap if we use a 64-bit processor?