Tech Quiz: Some micro optimization

Optimize the following code: doubletotalCount = 0; for (int index = 0; index < numberOfRuns; index++) {     string[] values = GetData(index);     totalCount += values.Count(); } Answer A simple optimization is to replace Count() with Length. Count() is an extension method that looks something like this: public static int Count<TSource>(this IEnumerable<TSource> source){    if (source == null)    { ...

TechQuiz Question 7: Calling derived methods..

What is the result of the following code? using System; class Base {     public virtual void Foo(int x) { Console.WriteLine(“Base.Foo(int)”); } } class Derived : Base {     public override void Foo(int x)  { Console.WriteLine(“Derived.Foo(int)”); }     public void Foo(object o)  { Console.WriteLine(“Derived.Foo(object)”); } } class Test {     static void Main()     {         Derived d = new...