hi i m making a window application in which i want to make a program of ascending or descending the numbers.
in console it is quite easy, but in window application it will create a problem.
means what i want is when i enter some numbers in textbox like 23, 5, 7, 987, 4567,....and when i click on button so it will give me a sorted list in another textbox.
can anyone tell me how can i do it in C# window application.
kindly give me code, if possible
Loading
Sanjay ChauhanPosted Aug 10, 2009, 8:38 AM
I am putting the code here for descending order sort
private void button1_Click(object sender, EventArgs e)
{
string[] mySplit = textBox1.Text.Split(new string[] { "," }, StringSplitOptions.None);
int[] intarray = Array.ConvertAll
string desText = "";
ArraySorter
for (int i = 0; i < intarray.Length; i++)
{
desText += intarray[i].ToString()+",";
}
textBox1.Text = desText;
}
static public class ArraySorter
where T : IComparable
{
static public void SortDescending(T[] array)
{
Array.Sort
}
static private ReverseComparer s_Comparer = new ReverseComparer();
private class ReverseComparer : IComparer
{
public int Compare(T object1, T object2)
{
return -((IComparable)object1).CompareTo(object2);
}
}
}
Anurag GuptaPosted Aug 11, 2009, 8:53 AM
hi sanjay.
can u tell me one more thing.
i m making a window application in which i want to find n-digit number in all.
i mean like i have a textbox in which i can enter any digit, like 1,2,3,4,5........
suppose i m entering 7 and after that when i click on button then it will show the total 7 digit numbers in another textbox.
like the max. number of 7 digit is 9999999 and min 7 digit number is 1000000 , so the total 7 digit number will be
((max-min)+1) this is the formula.
so can u tell me how can i do this with the help of C# window application?
Anurag GuptaPosted Aug 10, 2009, 9:12 AM
thanks 4 ur rply.
it works
Anurag GuptaPosted Aug 10, 2009, 9:11 AM
thanks 4 ur rply.
it works