Im passing a long string to a method that will return the first 20 words, however when i return the value the old value is still in the string. any ideas? My code is as follows:
string textContent = txtDiaryText.Text.ToString().Trim();
int NumberOfWords = 20;
getLimitedWords(textContent, NumberOfWords);
{
//do stuff with returned value;
}
public string getLimitedWords(string textContent, int NumberOfWords)
{
string[] Words = textContent.Split(' ');
string _return = string.Empty;
if (Words.Length <= NumberOfWords)
{
_return = textContent;
}
else
{
for (int i = 0; i < NumberOfWords; i++)
{
_return += Words.GetValue(i).ToString() + " ";
}
}
textContent = _return.ToString();
return textContent;
}