I'm new. I'm trying to take the pigTalk() and transfer it into its own class Thanks for any help
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FunctionTest
{
public class Program
{
public static void pigTalk(string sentence)
{
try
{
while (sentence != "exit")
{
string firstLetter;
string afterFirst;
string pigLatinOut = "";
int x;
string vowel = "AEIOUaeiou";
string[] pieces = sentence.Split();
foreach (string piece in pieces)
{
afterFirst = piece.Substring(1);
firstLetter = piece.Substring(0, 1);
x = vowel.IndexOf(firstLetter);
if (x == -1)
{
pigLatinOut = (afterFirst + firstLetter + "ay ");
}
else
{
pigLatinOut = (firstLetter + afterFirst + "way ");
}
Console.Write(pigLatinOut);
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
public static void Main(string[] args)
{
Console.WriteLine("Enter a sentence to convert into PigLatin");
string sentence = "";
sentence = Console.ReadLine();
pigTalk(sentence);
}
}
}