Category 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  

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  

Iterating over a custom ‘Jagged Array’ in Python

A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays." C# natively differentiates between a jagged and a multidimensional array. To iterate over a every single element of a Jagged Array in […]

0