Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CompareCharArrays
- {
- class CompareCharArrays
- {
- static void Main()
- {
- Console.WriteLine("Enter elements of first char array.");
- string firstArrStr = Console.ReadLine();
- Console.WriteLine("Enter elements of second char array.");
- string secondArrStr = Console.ReadLine();
- char[] firstArr = firstArrStr.ToCharArray();
- char[] secondArr = secondArrStr.ToCharArray();
- int firstArrLength = firstArr.Length;
- int secondArrLength = secondArr.Length;
- int minLength = Math.Min(firstArrLength, secondArrLength);
- for (int i = 0; i < minLength; i++)
- {
- if (firstArr[i] == secondArr[i])
- {
- continue;
- }
- else
- {
- if (firstArr[i] < secondArr[i])
- {
- Console.WriteLine("The first array elements come before the second's.");
- }
- else
- {
- Console.WriteLine("The second array elements come before the first's.");
- }
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment