TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ritika Roy
NA
2
2.6k
Problem in String Sorting in C#
Apr 17 2015 2:58 AM
Sir plzz help me to solve this error, The below code is work fine but when i replace
for(i=0; i<size; i++) to
for(i=1; i<=size; i++)
it shows exception .why?
using System;
public class ArrName
{
public static void Main()
{
string min,temp;
Console.Write("Enter the no. of Application: ");
int size = Convert.ToInt32(Console.ReadLine());
int loc,i,j;
string[] arr = new string[size];
Console.WriteLine("Enter proper name of each Student: ");
for(i = 0; i<size; i++)
{
Console.Write("{0}. ",i);
arr[i] = Console.ReadLine();
}
Console.WriteLine();
Console.ReadLine();
Console.WriteLine("Name After Arrange them in Alphabetical order: ");
for(i = 0; i<size; i++)
{
min = arr[i];
loc = i;
for(j = i+1; j<size; j++)
{
if((arr[j].CompareTo(min))<0 )
{
min = arr[j];
loc = j;
}
if(loc != i)
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
for(i = 0; i<size; i++)
{
Console.WriteLine(" {0}", arr[i]);
}
Console.ReadKey();
}
}
Reply
Answers (
2
)
Online database
How To fire rowcell click event in grid?