r_keya

r_keya

  • NA
  • 9
  • 0

Convert the following code to C# from Vb.Net

Sep 15 2004 11:59 AM
Are the following equivalent? Vb -> sGMnvm = new string(Chr(0), 100); C# -> sGMnvm = new string(Convert.ToChar(null), 100); Vb -> if (Asc(Mid(sPhone, iString, 1)) > 57 | Asc(Mid(sPhone, iString, 1)) < 48) C# -> if(Convert.ToChar(sPhone.Substring(iString,1))>15 || Convert.ToChar (sPhone.Substring(iString,1))<48) Vb -> string sQ = Chr(34); C# -> string sQ = " "; Vb -> sGMnvm = new string(Chr(0), 100); C# -> sGMnvm = new string(Convert.ToChar(null), 100); Vb-> iBit = Asc(Mid(sLicFinal, iCount, 1)); iBit = 65 + 122 - iBit; sBit = Chr(iBit); C# -> Don't know how to get the Chr(iBit) part! Vb -> iLicLen = Len(RTrim(sLicNo)); C# -> iLicLen = sLicNo.TrimEnd(null).Length; Vb -> sNum = sNum + LTrim(Str(Asc(Mid(sLicNo, iCount, 1)) - 65)); C# -> sNum = sNum + (Convert.ToChar(sLicNo.Substring(iCount,1))-65); What does Str do? Vb -> sLicFinal = Left(sLicFinal, iLen); C# -> sLicFinal = sLicFinal.Substring(sLicFinal.Length - iLen); Vb-> sLicNo = Right(sLicFinal, iBit); C# -> sLicNo = sLicFinal.Substring(sLicFinal.Length-iBit); Vb -> if (iLen / 2 == Int(iLen / 2)) //truncates decimal??? C#-> if((iLen/2)== System.Decimal.Truncate(iLen/2))] OR C# -> if (iEnd / 2 == int.Parse(iEnd/2)) // In place of Int(iEnd/2) I would really appreciate if someone checked these to see if I made the conversions right and help me understand what is going on. Lot of the stuff I don't even know what it is doing for sure. Thanks a lot. Keya

Answers (1)