I am trying to convert this Java (Android) code to c# (MonoDroid) but I don’t understand the <Item extends OverlayItem>
public class BalloonOverlayView<Item extends OverlayItem> extends FrameLayout
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s adding a constraint to the type parameter. It’s analogous to the
whereclause in C#.In Java, you have:
Where
Itemis a type parameter that must subclass or implement typeOverlayItem. In C# this would be written as:You can see how the constraint is moved to the end, but otherwise analogous. It is very much common practice in C# to name type parameters prefixed with a
T, so I would recommend the nameTItemlike so:This helps make clear the pretty important distinction between type parameters and ordinary types.
For a discussion on when you’d want to use type constraints like this, I go into this at length in a previous answer.