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

3 c# java class

在Java中:

TokenStream my_stream = analyser_exclude.tokenStream(fieldName, my_reader);
TermAttribute my_token = TermAttribute.getAttribute(TermAttribute.class);
Run Code Online (Sandbox Code Playgroud)

在VB.NET中:

Dim my_stream As TokenStream = analyser_exclude.TokenStream("", my_reader)
Dim my_token As TermAttribute = DirectCast(my_stream.GetAttribute(GetType(TermAttribute)), TermAttribute)
Run Code Online (Sandbox Code Playgroud)

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

在C#:???

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

Meh*_*dad 12

您正在寻找typeof:

TermAttribute my_token =
    (TermAttribute)my_stream.GetAttribute(typeof(TermAttribute));
Run Code Online (Sandbox Code Playgroud)