Reputation: 21
I want order descending as ascending my Textbox.Lines.
Textbox1.Lines
13
71
68
101
54
Output: Expecting
101
71
68
54
13
<<<<<<<<<<<<<<<<<<<<<<<
Dim lines() As String = TextBox1.Lines
Dim value As New System.Collections.Generic.List(Of Integer)
For Each line As String In lines
value.Add(Convert.ToInt32(line))
Next
value.Sort()
TextBox2.Text = value.ToString
Linq:
Dim lines() As String = Textbox1.Lines
Dim value = lines.Select(Function(x) Convert.ToInt32(x)).OrderByDescending(Function(x) x)
Textbox2.Text = value.tostring
So what i'm wrong?
Upvotes: 0
Views: 122
Reputation: 216293
value.ToString will just output the type of the object because an array of integers doesn't know how to print its single elements. You should join together the elements and print the resulting string
Textbox2.Text = String.Join(Environment.NewLine, value)
Upvotes: 1