Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case Again

Status
Not open for further replies.

paul84

Programmer
Jul 22, 2004
2
IE
HAs anyone got the correct code for dealing with switch case statements when you want to compare strings. At the moment i keep getting the error of comparing primitive data types to an object which is fare enough but thier must be some trick to fooling the compilier.

kind regards paul.
 
The short answer is no.

Switch statements only deal with primitives because the runtime only needs to allocate memory for the largest primitive available (in bits) - so the compiler treats the statements completely different to other comparable constructs. If this was not the case, then a switch would be nothing more than if/else - but the reason for its quickness is for the memory allocation reasons mentioned.

This was discussed in depth in this thread - thread269-874969

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top