locked
How to implement generic method? RRS feed

  • Question

  • I receive compile error 
    "cannot convert from 'T' to 'System.Collections.Generic.IEnumerable<string>"
    public void MyMethod <T>(T values)  
            {  
                int i = DoSmt(values);  
            }  
     
            int DoSmt(IEnumerable<string> values)  
            {  
                int i = 0;  
                foreach (string value in values)  
                {  
                    i += value.Length;  
                }  
                return i;  
            }  
     
            int DoSmt(string s)  
            {  
                return s.Length;  
            } 
    How to solve the problem?
    The beginning of discussion is here: http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/0853c977-af46-4212-a95b-2ece896dbc27
    Sunday, February 15, 2009 1:38 PM

Answers

All replies