i have a method, which should accept collection (perhaps IEnumerable<T> or List<T>) of any type (e.g. List<int> or List<string>).
inside of method i need to iterate collection and each element convert to string and add them together into one final string, like:
"(12, 123, 22)"
Problem is how to define that parameter collection can be of any type. I guess this is something about generics, but i do not know much about it.
However, i thing method definition should look something like this:
public string myMethod(List<T> list) { }
However, compiler does not allow it. Can you please tell me correct syntax?
or
Probably you may want to use
IEnumerable<T>because you need just to enumerate over the sequence.The same you can achieve using built-in functions:
See MSDN.