Home>

I'm sorry to hear the rudimentary things, but I would appreciate it if you could teach me.

pc: Windows 7
Development environment: Visual Studio 2008

I have a question about the sample code on the web.
Sort by List

The following error message occurred.

Error message
Error 1 The overloaded method best suited for 'string.Join (string, string [])' contains some invalid arguments.
Error 2 Argument '2': Cannot convert from 'System.Collections.Generic.List<int>' to 'string []'.
Applicable source code
static void Main (string [] args)
    {
      int [] src = {3, 1, 5, 4, 2};
      var list = new List<int>();
      // add element to list
      list.AddRange (src);
      // sort list
      list.Sort ();
      Console.WriteLine ("[{0}]", string.Join (",", list));
      Console.ReadKey ();
    }
Expected execution result
[1, 2, 3, 4, 5]

● Why does an error occur at the location of "string.Join ()"?

c#