Replace LinkedList element value through LinkedList.Enumerator
        Posted  
        
            by 
                Yan Cheng CHEOK
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Yan Cheng CHEOK
        
        
        
        Published on 2012-10-08T09:35:17Z
        Indexed on 
            2012/10/08
            9:37 UTC
        
        
        Read the original article
        Hit count: 504
        
c#
I realize there are no way for me to replace value through LinkedList.Enumerator. For instead, I try to port the below Java code to C#
            // Java
            ListIterator<Double> itr1 = linkedList1.listIterator();
            ListIterator<Double> itr2 = linkedList2.listIterator();
            while(itr1.hasNext() && itr2.hasNext()){
                Double d = itr1.next() + itr2.next();
                itr1.set(d);
            }
            // C#
            LinkedList<Double>.Enumerator itr1 = linkedList1.GetEnumerator();
            LinkedList<Double>.Enumerator itr2 = linkedList2.GetEnumerator();
            while(itr1.MoveNext() && itr2.MoveNext()){
                Double d = itr1.Current + itr2.Current;
                // Opps. Compilation error!
                itr1.Current = d;
            }
Any other technique I can use?
© Stack Overflow or respective owner