How to Sort the string

Posted by Mahesh_Chs under C# on 4/14/2012 | Points: 10 | Views : 1109 | Status : [Member] | Replies : 8
hi,

In Windows Application i am taking 2 textboxes and i am entering data(both numbers and charecters) in one textbox and i will click on a button and the sorted string should be displayed on 2nd textbox.

Thank You,
Mahesh.




Responses

Posted by: Somasundaram on: 4/14/2012 [Member] Starter | Points: 25

Up
0
Down
Pls explain your question properly...
What did u mean by sorted string???

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/14/2012 [Member] Silver | Points: 25

Up
0
Down
in textbox1 u enter at a tme only char or number? i can't understand ur ques.

Regards,
Singaravel M

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mahesh_Chs on: 4/14/2012 [Member] Starter | Points: 25

Up
0
Down
hi

i will enter both the charecters and integers in the textbox1, when i press the button i want to sort whole string in textbox1 and it should print in textbox2

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/14/2012 [Member] Silver | Points: 25

Up
0
Down
first get the textBox1 values to characters wise..

dim charstr as string()=textBox1.text.ToCharArray()


now u can sort charstr variable using Sort()....

Regards,
Singaravel M

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Refer This link

http://www.dotnetperls.com/sort

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Refer This link
http://www.dotnetperls.com/alphabetize-string

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Refer This link

http://www.dotnetperls.com/sort-strings-length

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 6/8/2012 [Member] Starter | Points: 25

Up
0
Down
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
static void Main()
{
// Initialize a List of strings.
List<string> sampleList = new List<string>
{
"stegosaurus",
"piranha",
"leopard",
"cat",
"bear",
"hyena"
};
// Send the List to the method.
foreach (string s in SortByLength(sampleList))
{
Console.WriteLine(s);
}
}

static IEnumerable<string> SortByLength(IEnumerable<string> e)
{
// Use LINQ to sort the array received and return a copy.
var sorted = from s in e
orderby s.Length ascending
select s;
return sorted;
}
}

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response