Archive for September, 2008

Reflection tip, IsOverridden

Friday, September 19th, 2008

Reflection is a power tool of managed language like Java and .NET (C#, VB.NET,C++/CLI and others). In the last days I have discovered that MethodInfo class don’t provide a method to check if is overridden or not.This activity is vary simple but on internet you can found a dozen of example about Reflection without one about this case.


   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Text;
   4:  using System.Reflection;
   5:  
   6:  namespace ReflectionMethod
   7:  {
   8:      internal class Program
   9:      {
  10:          static void Main(string[] args)
  11:          {
  12:              BaseClass derived = new DerivedClass();
  13:  
  14:              Type type = derived.GetType();
  15:  
  16:              MethodInfo method1 = type.GetMethod("Method2");
  17:  
  18:              Console.WriteLine(String.Format("This method is overridden? {0}",
  19:                  IsOverridden(method1)));
  20:  
  21:              Console.ReadKey();
  22:          }
  23:  
  24:          public static Boolean IsOverridden(MethodInfo info)
  25:          {
  26:              MethodInfo baseDef = info.GetBaseDefinition();
  27:  
  28:              return !(info.DeclaringType.FullName == baseDef.DeclaringType.FullName);
  29:          }
  30:      }
  31:  }

Hug a developer today

Sunday, September 14th, 2008

Thanks Franks

Rapporti…

Sunday, September 14th, 2008

A destra uno storico 20SC (che fa la polvere sul mio scaffale :-( ) a sinistra una comune micro SD della SanDisk. Il primo 20 MB il secondo nella foto 1GB. Un rapporto di 1 : 50 di capacita. Di dimensioni:

  • Micro SD: 15 mm × 11 mm × 1 mm
  • 20SC: invece 70 mm 240 mm x 265 mm

Volume :

  • Micro SD: 165 mm3
  • 20SC: 4452000 mm3

Il che significa che il 20SC è 27 mila volte più grande della Micro SD  :-o