我必須的代碼的那些行轉換爲C尖銳升C查詢錯誤
//VB Code:
Dim Query As String = "UPDATE Lidhja_Sh_A_M SET [email protected]_A, [email protected]_Sh, [email protected]_M WHERE [email protected]_L"
Dim cmd As SqlCommand = New SqlCommand(Query, con)
cmd.Parameters.AddWithValue("@Id_A", Trim(Me.txbIDLA.Text))
cmd.Parameters.AddWithValue("@Id_Sh", Trim(Me.txbIDLSh.Text))
cmd.Parameters.AddWithValue("@Id_M", Trim(Me.txbIDLM.Text))
// c sharp codes with error
cmd.Parameters.AddWithValue("@Id_A", Strings.Trim(this.txbIDLA.Text));
cmd.Parameters.AddWithValue("@Id_Sh", Strings.Trim(this.txbIDLSh.Text));
cmd.Parameters.AddWithValue("@Id_M", Strings.Trim(this.txbIDLM.Text));
哪裏是在C尖銳碼問題的問題???
我想知道爲什麼developerfusion的轉換器建議'Strings.Trim',如果這樣的東西不存在於C#中。 +1的問題。 – Neolisk
@Neolisk - 修剪只是一種方法,它在C#中完美可用。如果該方法被稱爲Foo,你會期望轉換器只是省略它嗎?它怎麼知道?更安全的過程是轉換它的內容並假定正確的程序集被引用。 –
@ChrisDunaway:當我嘗試在一個全新的C#項目中使用「Strings.Trim」時,它不起作用。我做錯了什麼?只是把'var a = Strings.Trim(「123」);'它說'名字'字符串'在當前上下文中不存在'。我嘗試過'使用Microsoft.VisualBasic;',但它沒有幫助。我的假設是,就編譯器而言,代碼轉換器應該生成完全有效的代碼。如果不能,它會顯示警告。 – Neolisk