{
case 1:
.....................
case 2:
.......................
case 3:
........................
case 4:
...........................default: ..........................
} 看了下论坛,有网友说可以使用hash函数替代的方法,如: switch ( hash( somestring ) )
{
case xxx : // xxx = hash( "your string1" );
...
} 还有网友指出可以用查表的方法实现,如:TStrings *ss = new TStringList();
ss->Add( "Your string1" );
ss->Add( "Your string2" );
...
switch( ss->IndexOf( somestring ) )
{
0 : // Your string1
1 : // Your string2
...
default : // Invalid
}
delete ss; 上述两种方法我均没有测试过,感兴趣的朋友可以搞一下。