我有这样的代码string.compare和字符串比较
private void btnStartAnalysis_Click(object sender, EventArgs e)
{
//Checks for the selectedItem in the cmbOpearions dropdown and make call to appropriate functions.
if((string) (cmbOperations.SelectedItem) == "PrimaryKeyTables")
{
//This is the function call for the primary key checking in DB
GetPrimaryKeyTable();
}
//Checks for the selectedItem in the cmbOpearions dropdown and make call to appropriate functions.
if((string) (cmbOperations.SelectedItem) == "NonPrimaryKeyTables")
{
//This is the function call for the nonPrimary key checking in DB
GetNonPrimaryKeyTables();
}
//Checks for the selectedItem in the cmbOpearions dropdown and make call to appropriate functions.
if((string) (cmbOperations.SelectedItem) == "ForeignKeyTables")
{
//This is the function call for the nonPrimary key checking in DB
GetForeignKeyTables();
}
//Checks for the selectedItem in the cmbOpearions dropdown and make call to appropriate functions.
if((string) (cmbOperations.SelectedItem) == "NonForeignKeyTables")
{
//This is the function call for the nonPrimary key checking in DB
GetNonForeignKeyTables();
}
if((string) (cmbOperations.SelectedItem) == "UPPERCASEDTables")
{
//This is the function call for the nonPrimary key checking in DB
GetTablesWithUpperCaseName();
}
if((string) (cmbOperations.SelectedItem) == "lowercasedtables")
{
//This is the function call for the nonPrimary key checking in DB
GetTablesWithLowerCaseName();
}
}
但这里使用(串),使问题的情况下,sensitiveness.So我要到位(串)的使用string.comapare。
任何人都可以给我任何提示如何使用它。
查看我的答案,为什么我不会使用`Compare`。另外还不清楚switch/case如何与此相关。 – 2010-11-30 07:58:07