Umwandlung kann ich nicht scheinen, dies, nachdem es auf C#Ungültige Basisfehler, wenn Java Base-27-Umwandlungsfunktion auf C#
Umwandlung zu arbeitenich es brauche, wie die Java ein zu arbeiten, aber ich kann nicht scheinen zu in der Lage sein, das zu tun, was mache ich falsch?
Kann jemand eine Reparatur liefern und es bitte erklären?
C#:
public static string Encrypt1(string strIn)
{
string strOut = "";
int lenIn = strIn.Length;
int i = 0;
while (i < lenIn)
{
double numRand = (int)Math.Floor(new Random().NextDouble() * 66) + 36;
strOut += Convert.ToString((int)(strIn[i] + (char)numRand), 27) +
Convert.ToString((int)numRand, 27);
i++;
}
return strOut;
}
Java:
public String Encrypt1(String strIn) {
String strOut = "";
int lenIn = strIn.length();
int i = 0;
double numRand;
while (i < lenIn) {
numRand = Math.floor(Math.random() * 66) + 36;
strOut += Integer.toString((int)(strIn.charAt(i) + (char)numRand), 27) +
Integer.toString((int)numRand, 27);
i++;
}
return strOut;
}
Der Fehler:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Invalid Base.
Fehlerzeile:
strOut += Convert.ToString((int)(strIn[i] + (char)numRand), 27) +
Convert.ToString((int)numRand, 27);
'numRand = Math.floor (Math.random() * 66) + 36;' sagt 36 in Java und 33 in C# –
i geändert sehen, aber noch nicht das gleiche Ergebnis ty. – Punxor
Was genau versuchen Sie zu erreichen und welche Fehler bekommen Sie? – galacticfan