I'm trying to create a program that splits a string to an array then adds to that array.
Splitting the string works but adding to the array is really putting up a fight.
//here i create the text
string text = Console.ReadLine();
Console.WriteLine();
//Here i split my text to elements in an Array
var punctuation = text.Where(Char.IsPunctuation).Distinct().ToArray();
var words = text.Split().Select(x => x.Trim(punctuation));
//here i display the splitted string
foreach (string x in words)
{
Console.WriteLine(x);
}
//Here a try to add something to the Array
Array.words(ref words, words.Length + 1);
words[words.Length - 1] = "addThis";
//I try to display the updated array
foreach (var x in words)
{
Console.WriteLine(x);
}
//Here are the error messages |*error*|
Array.|*words*|(ref words, words.|*Length*| + 1);
words[words.|*Length*| - 1] = "addThis";
'Array' does not contain definition for 'words'
Does not contain definition for Length
Does not contain definition for length */