Introduction: Converting string from lowercase to uppercase without using any inbuilt function, in C#.
Program
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace LowerTOUpper
- {
- class LowerTOUpper
- {
- public static String ConvertToUpperCase(String input)
- {
- String output = "";
- for (int i = 0; i < input.Length; i++)
- {
- if (input[i] >= 'a' && input[i] <= 'z')
- {
- output += (char)(input[i] - 'a' + 'A');
- }
- else
- output += input[i];
- }
- return output;
- }
-
- static void Main(string[] args)
- {
- System.Console.Write("Enter a string: ");
- String input = System.Console.ReadLine();
- input = ConvertToUpperCase(input);
- System.Console.WriteLine("Converted String in Upper Case: " + input);
- Console.ReadLine();
- }
- }
- }
Output