Click here to Skip to main content
15,898,036 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Classic Pin
dean.wilde9-Aug-07 12:40
dean.wilde9-Aug-07 12:40 
Generaltypeof(string)? Meh. Pin
DavidNohejl23-Jul-07 5:59
DavidNohejl23-Jul-07 5:59 
GeneralRe: typeof(string)? Meh. Pin
PIEBALDconsult23-Jul-07 8:27
mvePIEBALDconsult23-Jul-07 8:27 
GeneralRe: typeof(string)? Meh. Pin
DavidNohejl23-Jul-07 8:32
DavidNohejl23-Jul-07 8:32 
GeneralRe: typeof(string)? Meh. Pin
PIEBALDconsult23-Jul-07 8:37
mvePIEBALDconsult23-Jul-07 8:37 
GeneralRe: typeof(string)? Meh. Pin
Paul Conrad23-Jul-07 12:11
professionalPaul Conrad23-Jul-07 12:11 
GeneralRe: typeof(string)? Meh. Pin
Andy Brummer23-Jul-07 8:46
sitebuilderAndy Brummer23-Jul-07 8:46 
GeneralRe: typeof(string)? Meh. Pin
dojohansen20-Aug-07 2:51
dojohansen20-Aug-07 2:51 
I believe the typeof(T) operator is resolved at compile-time. Thus when you speak of how long "typeof took" you are really only measuring the time spent to loop, increment and check loop variable, and perform the assignment.

The MSDN documentation does make a distinction between types in general and the type objects that represent types (and which are, of course, themselves types). For example, the reference for the typeof() operator mentions:

Used to obtain the System.Type object for a type. A typeof expression takes the following form:
System.Type type = typeof(int);

It's clear that the System.Type is the "metatype", the type that is created for us but describes a type we created.

It also says to use GetType() to obtain the run-time type of an expression (although not the GetType overload discussed here, taking a string and finding a corresponding type in any loaded assembly in the appdomain!), and I take this as evidence in support of the "typeof() is resolved at compile-time" hypothesis. Smile | :)

GeneralRe: typeof(string)? Meh. Pin
PaulPrice23-Jul-07 9:59
PaulPrice23-Jul-07 9:59 
GeneralRe: typeof(string)? Meh. Pin
DavidNohejl23-Jul-07 12:09
DavidNohejl23-Jul-07 12:09 
GeneralRe: typeof(string)? Meh. Pin
PaulPrice23-Jul-07 12:55
PaulPrice23-Jul-07 12:55 
GeneralRe: typeof(string)? Meh. Pin
Vasudevan Deepak Kumar28-Jul-07 22:15
Vasudevan Deepak Kumar28-Jul-07 22:15 
GeneralRe: typeof(string)? Meh. Pin
Paul Conrad23-Jul-07 12:12
professionalPaul Conrad23-Jul-07 12:12 
GeneralRe: typeof(string)? Meh. Pin
leppie25-Jul-07 2:52
leppie25-Jul-07 2:52 
GeneralRe: typeof(string)? Meh. Pin
Vasudevan Deepak Kumar28-Jul-07 22:14
Vasudevan Deepak Kumar28-Jul-07 22:14 
GeneralRe: typeof(string)? Meh. Pin
DavidNohejl29-Jul-07 3:12
DavidNohejl29-Jul-07 3:12 
GeneralLinks show open-save dialog box Pin
matjame18-Jul-07 0:33
matjame18-Jul-07 0:33 
GeneralRe: Links show open-save dialog box Pin
Paddy Boyd18-Jul-07 0:41
Paddy Boyd18-Jul-07 0:41 
GeneralRe: Links show open-save dialog box Pin
matjame18-Jul-07 0:44
matjame18-Jul-07 0:44 
GeneralRe: Links show open-save dialog box Pin
Jigar K Oza18-Jul-07 1:37
Jigar K Oza18-Jul-07 1:37 
GeneralRe: Links show open-save dialog box Pin
Vasudevan Deepak Kumar24-Jul-07 2:06
Vasudevan Deepak Kumar24-Jul-07 2:06 
GeneralRe: Links show open-save dialog box Pin
dojohansen20-Aug-07 2:54
dojohansen20-Aug-07 2:54 
GeneralWhen normalization goes wrong. Horribly. Pin
martin_hughes15-Jul-07 9:12
martin_hughes15-Jul-07 9:12 
GeneralRe: When normalization goes wrong. Horribly. Pin
Pete O'Hanlon15-Jul-07 9:22
mvePete O'Hanlon15-Jul-07 9:22 
GeneralRe: When normalization goes wrong. Horribly. Pin
Paul Conrad15-Jul-07 9:25
professionalPaul Conrad15-Jul-07 9:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.