Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Methods
- {
- public class Methods
- {
- public static void Main()
- {
- string type = Console.ReadLine().ToLower();
- var value1 = Console.ReadLine();
- var value2 = Console.ReadLine();
- if (type == "int")
- {
- int number = int.Parse(value1);
- int number2 = int.Parse(value2);
- int maxInt = GetMax(number, number2);
- Console.WriteLine(maxInt);
- }
- else if (type == "char")
- {
- char char1 = char.Parse(value1);
- char char2 = char.Parse(value2);
- char maxChar = GetMax(char1, char2);
- Console.WriteLine(maxChar);
- }
- else if (type == "string")
- {
- string string1 = value1;
- string string2 = value2;
- string maxString = GetMax(string1, string2);
- Console.WriteLine(maxString);
- }
- }
- static int GetMax(int number, int number2)
- {
- if (number > number2)
- {
- return number;
- }
- else
- {
- return number2;
- }
- }
- static char GetMax(char char1, char char2)
- {
- if (char1 > char2)
- {
- return char1;
- }
- else
- {
- return char2;
- }
- }
- static string GetMax(string string1, string string2)
- {
- if (string.Compare(string1, string2, StringComparison.Ordinal) >= 0)
- {
- return string1;
- }
- else
- {
- return string2;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement