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

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

How to Share webservice object to all user

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts