Browse by Tags

All Tags » C# » C# 3.0 (RSS)
This piece of code results in a warning. 1: class Test 2: { 3: public static void Main() 4: { 5: object obj = "Senthil" ; 6: string myName = "Senthil" ; 7: Console.WriteLine(obj == myName); 8: } 9: } The compiler says “warning CS0252...
Posted by Senthil | with no comments
Filed under: , ,
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 | 2 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: , ,
If you’ve done any multithreading programming at all, you must be aware of the volatile modifier. When a field is marked volatile, it tells 1. the JIT compiler that it can’t hoist the field because it may be modified by multiple threads 2. the CLR that...
Posted by Senthil | 5 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: , ,
I'll bet a hundred bucks that any entry level C++ interview or exam will somehow drift into questions about the pre and post increment operators. It's almost become a canonical, rite of passage sort of thing. Now using the operators is one thing...
Posted by Senthil | with no comments