I'm trying to return an array of strings but return test; only gives "System.String[]" as output. If I iterate through test[] all values are filled in correctly. What am I doing wrong?
 public static String[] ReturnTheStrings()
 {
     FillTheArray();
     String[] test = new String[178];
     for (int i = 0; i < 178; i++)
     {
         if ((Class7.Method4(strings[i])) == "decoding wrong")
         {
             test[i] = strings[i+1];
             //System.Console.WriteLine("Non-encoded value");
         }
         else
         {
             test[i] = Class7.Method4(strings[i+1]);
             //System.Console.WriteLine("Encoded value");
         }
     }
     return test;
 }
I'm using MS Visual C# 2010.
Calling .ToString() on an array will return "System.String[]". If you want to display each value in the array, you have iterate over it.
For example:
foreach (var value in test)
{
    Console.WriteLine(value);
}
Or, as @Oded pointed out in the comments, you can use String.Join:
Console.WriteLine(String.Join(Environment.NewLine, stringArray));
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With