I am attempting to make a method that's used to search for a word in a paragraph that asks the user for the word but I get the error "Argument 2 must be passed with the 'ref' keyword." when trying to call my GetString method from my input.cs. I'm trying to associate the word "find" for the parameter but I'm having a hard time trying to figure this out and would appreciate any help.
Below is my SearchWord method in Program.cs.
public static void SearchWord(Dictionary<string, int> word)
{
string find = "";
string choice = Input.GetString("\nWhat word are you searching for? ", find);
if (word.ContainsKey(choice))
{
PrintKeyValueBar(choice, word[choice]);
string[] sentences = GetSpeech().Split(new char[] {'.',' ',',','!','?',':','\n','\t','\r'});
foreach (string sentence in sentences)
{
if (sentence.Contains(choice))
{
Console.WriteLine(sentence);
}
}
}
else
{
Console.WriteLine($"{choice} is not found.");
}
}
Thank you in advance for the assistance.
EDIT. Adding the GetString method in Input.cs
public static void GetString(string prompt, ref string value)
{
while (true)
{
value = GetInput(prompt);
if (ValidString(prompt))
{
break;
}
Console.WriteLine("That's not right");
}
}
Class instructions state "Use GetString to get the word from the user!" but when trying to do so I get the error.
I have tried string ref find = "";, ref find = ""; ref string find "";