Why isn't String.Join working the way I though it would?
i have following code:
public void encypt(string input) { int[] numarray = input.tochararray().select(x => int.parse(x.tostring())).toarray(); int[] encryptarray = new int[4]; numarray[0] += 7; numarray[1] += 7; numarray[2] += 7; numarray[3] += 7; numarray[0] %= 10; numarray[1] %= 10; numarray[2] %= 10; numarray[3] %= 10; encryptarray[0] = numarray[2]; encryptarray[1] = numarray[3]; encryptarray[2] = numarray[0]; encryptarray[3] = numarray[1]; string output = string.join("", encryptarray.tostring()); console.writeline(output); }
what thought happen output string of in encryptarray array. instead, system.int32[];
i tried this:
foreach (int digit in encryptarray) { output = string.join("", encryptarray.tostring()); } console.writeline(output);
which gave me same answer , tried this:
foreach (int digit in encryptarray) { output = string.join("", encryptarray.tostring()); console.writeline(output); }
which gave me system.int32[] 4 times.
please advise why it's not working way thought would. thank you.
hello,
if lose .tostring() string string.join method.
public string encypt(string input) { int[] numarray = input.tochararray().select((x) => int.parse(x.tostring())).toarray(); int[] encryptarray = new int[4]; numarray[0] += 7; numarray[1] += 7; numarray[2] += 7; numarray[3] += 7; numarray[0] = numarray[0] % 10; numarray[1] = numarray[1] % 10; numarray[2] = numarray[2] % 10; numarray[3] = numarray[3] % 10; encryptarray[0] = numarray[2]; encryptarray[1] = numarray[3]; encryptarray[2] = numarray[0]; encryptarray[3] = numarray[1]; return string.join("", encryptarray); }
please remember mark replies answers if , unmark them if provide no help, others looking solutions same or similar problem.
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment