how can modify or add new item into generic list of string's
        Posted  
        
            by Sadegh
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sadegh
        
        
        
        Published on 2010-05-24T12:42:57Z
        Indexed on 
            2010/05/24
            12:51 UTC
        
        
        Read the original article
        Hit count: 295
        
c#
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?
© Stack Overflow or respective owner