user1056113
user1056113

Reputation:

what is the equivalent of .class (used in Java) in C#

In Java :

TokenStream my_stream = analyser_exclude.tokenStream(fieldName, my_reader);
TermAttribute my_token = TermAttribute.getAttribute(TermAttribute.class);

In VB.NET :

Dim my_stream As TokenStream = analyser_exclude.TokenStream("", my_reader)
Dim my_token As TermAttribute = DirectCast(my_stream.GetAttribute(GetType(TermAttribute)), TermAttribute)

I just changed the fieldname in VB.NET because I didn't need it. This code works in VB.NET but I don't know how to change the DirectCast in C# and the last line of code with (in Java) Termattribute.Class

In C# : ???

Help me please I don't know how to change those lines in C#.

Upvotes: 5

Views: 4747

Answers (1)

user541686
user541686

Reputation: 210705

You're looking for typeof:

TermAttribute my_token =
    (TermAttribute)my_stream.GetAttribute(typeof(TermAttribute));

Upvotes: 15

Related Questions