Tag Archives: c#

Do Value Types in C# always go on the stack?

It is quite well-known that value-types are created on the Stack (sometimes in registers as well depending on the allocation strategy) and reference types are based in the Heap area of memory. But when you are creating a custom type and you wish to embed value types in there, where would they reside? So it […]

0  

Another way to print hex value in C++

You can simply use the std::hex base format flag! This also works with oct and dec. #include <iostream> int main() { std::cout << "Value of 10 in hex: " << std::hex << 10 << std::endl; std::cout << "Value of 10 in dec: " << std::dec << 10 << std::endl; std::cout << "Value of 10 in […]

0  

Restrict date range within DatePicker component

So I had to restrict days in the WPF DatePicker component. Only the days falling within a specific range should be available for selection and all others (past & future values) should be disabled. The solution is to use the DisplayDateStart & DisplayDateEnd properties on the DatePicker <DatePicker Name="dtPicker" DisplayDateStart="5/10/2012" DisplayDateEnd="5/20/2012" />

0  

Achieving optimal performance in code

Is there any difference between the following two expressions\statements? def func1(a): return a == ‘TRUE’ def func2(a): return True if a == ‘TRUE’ else False Well, both of them do the same thing but interestingly, the former one is faster in terms of performance by atleast one CPU cycle! Let’s tear into assembly language of […]

0  

Logging in Java, C# and Python

In Java & C#, the most commonly used logging utilities are log4j and log4net. Python has it’s own inbuilt logging module which includes the exact same features as other log4X brethren! Setting up logging module in python >> import logging def initLogger(appName=’Application’, handlerType=’StreamHandler’, \ loggerLevel=’INFO’, handlerLevel=’DEBUG’): ”’ * There are many handler types available such […]

0