Bohn
Bohn

Reputation: 26919

Declaring a method that its parameter is a generic class

I have an interface defined like this:

public interface IOwlAnnotationTuple<T1, T2, T3>

and then also its class like this:

public class OwlAnnotationTuple : IOwlAnnotationTuple<string, OWLClass, string>

Then I have anther interface that I am adding a method to it which I want it to take a parameter of this interface I defined above, so I defined it like this but I get error that "> is expected."

void AddAnnotation(IOwlAnnotationTuple <string annotationName, OWLClass owlClass, string annotationValue>);

So what is the correct syntax of declaring it?

Upvotes: 0

Views: 62

Answers (1)

user743382
user743382

Reputation:

You've attempted to name three parameters, but if you only want a single one, only name the single one:

void AddAnnotation(IOwlAnnotationTuple<string, OWLClass, string> owlAnnotationTuple);

or

void AddAnnotation(OwlAnnotationTuple owlAnnotationTuple);

The type of owlAnnotationTuple is IOwlAnnotationTuple<string, OWLClass, string>. There are no separate parameters of types string/OWLClass, so you don't get to name those.

Upvotes: 3

Related Questions