2

Naive question about Java syntax. What does

<T> T accept(ObjectVisitorEx<T> visitor);

mean? What would be the C# equivalent?

Dervin Thunk
  • 19,515
  • 28
  • 127
  • 217

5 Answers5

2

In C# it could be:

O Accept<O>(ObjectVisitorEx<O> visitor);
bruno conde
  • 47,767
  • 15
  • 98
  • 117
1

This is used for passing types as parameters. C# syntax is the same (<Type>). Suggest googling for term 'generics' as this is the term you're looking for.

quosoo
  • 829
  • 4
  • 10
1

The C# equivalent would be more or less the same. If the visitor were an interface it would be

O Accept(IObjectVisitorEx<O> visitor);
AgileJon
  • 53,070
  • 5
  • 41
  • 38
1

Here's a good comparison between Java and C# generics.

Otávio Décio
  • 73,752
  • 17
  • 161
  • 228
0

see Java: http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html
and C#: http://msdn.microsoft.com/en-us/library/ms379564(VS.80).aspx
A similar C# method could be

public T Foo<T>(Queue<T> v) // Queue<T> chosen for simplicity
{
  return v.Dequeue();
}
VolkerK
  • 95,432
  • 20
  • 163
  • 226