什么是C#中的.class(在Java中使用)的等价物

问题描述:

在Java中:

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

在VB.NET中:

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

我刚刚在VB.NET中更改了字段名,因为我不需要它。此代码适用于VB.NET
,但我不知道如何更改C#中的DirectCast和最后一行代码(使用Java)Termattribute.Class

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

在C#中:
???

In C# : ???

请帮助我,我不知道如何在C#中更改这些行。

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

您正在寻找 typeof

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