在 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
在 C# 中: ???
请帮助我,我不知道如何在 C# 中更改这些行。
最佳答案
你正在寻找typeof
:
TermAttribute my_token =
(TermAttribute)my_stream.GetAttribute(typeof(TermAttribute));
关于c# - 什么是 C# 中的 .class (在 Java 中使用)的等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8200111/