I need to make function that determine longer word of two entered. I have tried to use if-statement and String.Length
, but I can't get it right. What would be the best way to make the function?
Below is the main program.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class LongerWord
{
public static void Main(string[] args)
{
Console.Write("Give 1. word >");
String word1 = Console.ReadLine();
Console.Write("Give 2. word >");
String word2 = Console.ReadLine();
String longer = LongerString(word1, word2);
Console.WriteLine("\"" + longer + "\" is longer word");
Console.ReadKey();
}
}