November 2008 Entries
Weird error that toke me a few autobot years to figure it out. Anyway, I got the following exception "System.Reflection.TargetException: Object does not match target type." when I tried to do some reflection, here is the code and off course as usual the error message wasn't descriptive enough. foreach (object obj in this.InnerList)
{
System.Reflection.PropertyInfo pi = obj.GetType().GetProperty(field);
if (pi != null && pi.GetValue(obj,null).Equals(value))
...
Lets say you have a collections class that implements the System.Collections.CollectionBase that handles a collection of your custom objects and allows you to enumerate and do other cool stuff but no sorting. I was recently faced with this scenario, I was faced with a collection that needs to be sorted by any property/field, I.e. lets say I have a product class, I want to be able to sort it by name, price, etc. just like you would in a database using Order By. First of, lets talk about IComparer which is very similar to IComparable but used for different...
Ok, not internship but intern, this is a brief post about string interning. Within the String namespace you will find the Intern and IsInterned methods. I've always been curious about what they do or why they are there, they are one of those things that you may never use in your whole development career. In the .Net Framework there are 3 types of functions & classes, 1. ones that you just have to use, 2. others that you use because you really need to, 3. and those that you use because you like to write complex stuff - this applies...
If you have ever done some profiling or tried to see how fast/slow certain stubs/snippets run, there is a good chance that you have written timers using the timer class that works very much like a stop watch. The idea usually is to see the elapse time of certain piece of snippet which usually helps us developers track down the bottle neck. With .Net 1.1 you pretty much had to write your own stop watch class and there are tons of them out there, Google the term "stopwatch class .net" and you will see for yourself. Anyway, with C#...
Next entries »