anndy smaals

anndy smaals

  • NA
  • 24
  • 3.9k

splitting a string into an array of strings

Dec 17 2018 5:45 PM
split the string into an array of strings, stored in the words string array,
and then find out which word is the longest, and copy that to the longestWord variable
 
using System;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
string lyric = "We've come a long long way together";
string[] words;
string longestWord;
words = lyric.Split(' ');
longestWord = lyric;
Console.WriteLine("There are " + words.Length + " words, and the longest is " + longestWord);
}
}

Answers (1)