Browse by Tags

All Tags » software (RSS)
Mixing SetEnvironmentVariable and getenv is asking for trouble, as we recently found to our dismay (and exasperation!). It took some serious debugging to figure out the actual problem – let’s see if you can figure it out. Here’s some C++/CLI code that...
The previous post discussed having anonymous methods as event handlers and ended with a question – why doesn’t unsubscription work while subscription works out alright? Vivek got the answer spot on – the way the C# compiler handles and translates anonymous...
Posted by Senthil | 2 comment(s)
Filed under: , , ,
The syntactic sugar offered by anonymous methods makes them great candidates for writing event handlers; together with smart type inference, they reduce the amount of code written by an order of magnitude. And that’s without considering the power offered...
Posted by Senthil | 6 comment(s)
Filed under: , , ,
You're writing this really cool and innovative class to calculate the first hundred thousand natural numbers. You think about the API, and you realize that returning an array of the numbers a) might take a long time to complete, and b) is going to...
Posted by Senthil | with no comments
Filed under: , ,
My colleague Soundar discovered this rather interesting behavior. 1: class Test 2: { 3: public static void Main() 4: { 5: Test test = null ; 6: 7: Console.WriteLine(" {0} ", test); 8: Console.WriteLine(" {0} ", null ); 9: } 10: } If...
Posted by Senthil | 4 comment(s)
Filed under: , ,
Take a look at the following short snippet of code. 1: using System; 2: 3: struct S 4: { 5: public int X; 6: } 7: 8: class C 9: { 10: /* More code here */ 11: } 12: 13: class Test 14: { 15: public static void Main() 16: { 17: C c = new C(); 18: c.S.X...
Posted by Senthil | 1 comment(s)
Filed under: , ,
Ever since I happened to stumble upon this book on Data Mining, I've been hooked. So much so that I've been brushing up on statistics and probability distributions just to follow along the book. I'm currently reading the chapter on classification...
If you use Skype , do you know that you can program against it? Head over to developer.skype.com if you're interested. There's a COM API, one for Java and even one for Python. Just to show how easy it is, we'll write a bot in .NET that will...
Posted by Senthil | 2 comment(s)
Filed under: , ,
There are times when you feel really proud of yourselves; on top of the world, with no one in sight. And then there are times when you can't believe you did what you just did. Here's one of the latter :- My task was to show a progress bar in our...
This is one topic that keeps popping up every now and then. A lot of people seem to be curious about the performance implications of using one versus the other, and not unexpectedly, a lot of different answers come up. To settle it once for all, here's...
Tee is a cool function that "clones" enumerators whatever their current state is - it basically allows you to branch off an enumerator into as many enumerators as you want, all independent of each other. You can do something like List<int>...
The observer effect "refers to changes that the act of observing will make on the phenomenon being observed.". How infuriating would be a bug that demonstrates that effect - things work when you see them, don't when you don't? There's...
Posted by Senthil | with no comments
Filed under:
What do you think of the following piece of code? class Program { int x = 1; int y = x + 1; } Looks simple, except that it doesn't compile (error CS0236: A field initializer cannot reference the non-static field, method, or property 'Program.x'...
Local variable type inferencing is a new feature in C# 3.5 - a very "handy" one, in that it saves a lot of typing. Basically, it lets you do var dict = new Dictionary<string, List<int, Dictionary<int, string>>>(); instead of...
Polymorphism, which attempts to hide differences in implementation, and generics, which attemtps to highlight them by providing exact information about types, don't seem to mix very well. Consider the following fairly common pattern. class Base {...
I've been dabbling with IronPython for the last few days, trying to host it and use it as a scripting engine. I have to say that I'm impressed. The hosting API is incredibly simple to use and Mike Stall's blog served as a handy reference....
Posted by Senthil | with no comments
Filed under: