how can modify or add new item into generic list of string's
- by Sadegh
hi, i want to remove some pretty words in list of words.
public System.String CleanNoiseWord(System.String word)
{
string key = word;
if (word.Length <= 2)
key = System.String.Empty;
else
key = word;
//other validation here
return key;
}
public IList<System.String> Clean(IList<System.String> words)
{
var oldWords = words;
IList<System.String> newWords = new string[oldWords.Count()];
string key;
var i = 0;
foreach (System.String word in oldWords)
{
key = this.CleanNoiseWord(word);
if (!string.IsNullOrEmpty(key))
{
newWords.RemoveAt(i);
newWords.Insert(i++, key);
}
}
return newWords.Distinct().ToList();
}
but i can't add, remove or insert any thing in list! and exception NotSupportedException occured Collection was of a fixed size. how i can modify or add new item into generic list of string's?