typeof or System.Type.GetType

  • Thread starter Thread starter Baccarin
  • Start date Start date
B

Baccarin

Hello C# gurus,

I would like your opinion. Who is quicker to obtain a
System.Type(): typeof() or System.Type.GetType()?

Regards,

Baccarin.
 
If you know the type, then use typeof. Otherwise, if you
depend on run-time info, then you have to use GetType().

Tu-Thach
 
Baccarin said:
I would like your opinion. Who is quicker to obtain a
System.Type(): typeof() or System.Type.GetType()?

Are you really getting a Type reference that often that it's likely to
make any difference? I would use typeof if you know the type name at
compile time, as then you get compile-time checking of spelling
mistakes. If you don't know the type name at compile time, you can't
use typeof anyway.
 
Back
Top