我有這樣的代碼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