When I was working on the .NET reflection extravaganza thing that I explained in my previous column, i learnt one another interesting thing, that is about the Type.InvokeMember. How will pass out or ref parameters for the method invoked using Type.InvokeMember ? If you are going to invoke a method with the prototype int DoSomething(string someString, int someInt); then you would use InvokeMember like this:- object obj = someType.InvokeMember("DoSomething", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, this, new object[] {"Largest Integer", 1}); or use some variables in the new object[] {...}. But what do you with the args if DoSomething takes out or ref parameters ? int DoSomething(out string someString, ref int someInt); Something like this will not work string someText = string.Empty; int someInt = 0; object obj = someType.InvokeMember("DoSomething", BindingFlags.Public | BindingFlags....
Another effective [debugging] technique is to explain your code to someone else. This will often cause you to explain the bug to yourself. Sometimes it takes no more than a few sentences, followed by an embarrassed "Never mind. I see what's wrong. Sorry to bother you." This works remarkbly well; you can even use non-programmers as listeners. - From "The Practice of Programming" by Brian W Kernighan & Rob Pike.