[英]what is the equivalent of .class (used in Java) in C#
在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中更改了fieldname,因為我不需要它。 這段代碼適用於VB.NET,但我不知道如何在C#中更改DirectCast以及使用(在Java中)Termattribute.Class中的最后一行代碼
在C#:???
請幫助我,我不知道如何在C#中更改這些行。
你正在尋找typeof
:
TermAttribute my_token =
(TermAttribute)my_stream.GetAttribute(typeof(TermAttribute));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.