我不是VB6-ish人。我只需要將一些代碼從VB6轉換爲我們項目的C#。 我對VB6
Comm_ReceiveData = Mid$(Comm_ReceiveData, 2, Len(Comm_ReceiveData))
這段代碼此代碼裏面Timer1_Timer()
子功能找到。
我轉換這條線到C#
Comm_ReceiveData = Comm_ReceiveData.Substring(1, Comm_ReceiveData.Length);
所以在C#,我接收到該錯誤。
Index and length must refer to a location within the string.
字符串Comm_ReceiveData是「01BP215009010137 \ r」。長度,我相信,是17
是的,我知道我會在C#中得到這種錯誤。我想知道爲什麼我不會在VB6上出錯。 是否有另一種方法將該VB6代碼轉換爲C#? VB6代碼對「越界」類錯誤不敏感嗎?
順便說一句,我正在使用該代碼進行串行通信。我得到了一個從我的arduino到C#/ VB6的字符串,我需要對它進行解碼。非常感謝你!
爲什麼二進制數據在字符串中? –