Reputation: 3611
How can i see the code inside of ForEach<T>(T[] array, Action<T> action)
?
Not the definition only or how to use but the code inside of this method?
I just need to see how to change the parameter type when i put T as a type passed on that method.
Example:
Array.ForEach<string>(string[] array, Action<string> action); Array.ForEach<int>(int[] array, Action<int> action); Array.ForEach<whateverTypeHere>(whateverTypeHere[] array, Action<whateverTypeHere> action);
If i put any type inside <> the parameters also will change. How to do it anyway? :)
Upvotes: 0
Views: 516
Reputation: 1074
public class Test<TFirst,TSecond>
{
public TFirst First;public TSecond Second;
}
if i create a new instance of this class, it will show like
Test<int,string> objName=new Test<int,string>{ First=1, Second="Microsoft"};
if you pass the type like int or string, automatically the compiler will infer the type of your property.
You have to try practicing it, then you will be able to understand
Upvotes: 3