When to use <> instead of ()

When we are suppose to use different parentheses in C#. When I run into a situation where i am trying to tell if i need to put <> or ().

The dumbed down version to explain is this;

() are for variables. <> are for types. If you have both, <> always comes first.

You would never has A(int). It would be A<int>. You’d also never have B<5>. It would always be B(5). And, rule two, you might have C<int>(5), but never C(5)<int>.

<> are used in generics.

FavoriteLoadingAdd to favorites
Spread the love

Author: Shahzad Khan

Software developer / Architect