-4

Hello this is my first time asking a question and I wanted to get that out of the way if I did something wrong you can tell me so I will learn from my mistakes. Now I was programming in c# and wanted to put system information into an array so I can I can put it into a list view in order I set. I was testing it out and found a problem and can't seem to fine a good answer with the time I spent looking and trying to fix myself. I converted the desktop name to string and put it into a string array and keep getting back System.String[]. Now I'm kinda new to c# and programming in generally as this is my first program by myself. If I made a simple mistake don't go to harsh as I'm still trying to learn myself.

My output https://i.stack.imgur.com/IxAaV.png My code https://i.stack.imgur.com/SunJ4.png

Mrigank Pawagi
  • 892
  • 1
  • 8
  • 26
Jacob Chafin
  • 130
  • 12
  • 1
    Please put your code in the question as text rather than as an image. – mjwills Jul 13 '17 at 12:37
  • 2
    1. You should put your code here in question, not a screenshot. 2. `WriteLine` method internally calls `information.ToSting();`. Variable `information` is string array, so it outputs the type of the variable. To get the value you put in array you need to access it by index. So to output first element you need to do `WriteLine(information[0]);` – Renatas M. Jul 13 '17 at 12:39
  • What you are trying to do is output an array of strings `string[]` in this case you can output the values of position 0 and 1 in the array instead. Ex. `Console.WriteLine(information[0]);` or `Console.WriteLine(string.Join(",", information));` – ZarX Jul 13 '17 at 12:39

1 Answers1

1

Guessing from your description and the images the problem is, that not the content of the array is printed? To solve this just iterate through the array and print each single string. E.g:

string[] toDisplay = {"text1", "text2"};
toDisplay.ToList().ForEach(subString => Console.WriteLine(subString));
royalTS
  • 603
  • 4
  • 22