在Roslyn(Microsoft CodeAnalysis)中,如何创建布尔文字? [英] In Roslyn (Microsoft CodeAnalysis) how do I create a boolean literal?

查看:69
本文介绍了在Roslyn(Microsoft CodeAnalysis)中,如何创建布尔文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常我会使用SyntaxFactory,但无法弄清楚如何用它创建一个真或假节点.

Normally I would use the SyntaxFactory but I cannot figure out how to create a true or false node with it.

推荐答案

我刚刚弄清楚了.true和false是关键字,我不必过多地处理关键字,因此我在寻找错误的地方.关键字显然倾向于依靠拥有自己的SyntaxKind.

I just figured it out. true and false are keywords and I haven't had to deal with keywords much so I was looking in the wrong spot. Keywords apparently tend to rely on having their own SyntaxKind.

SyntaxFactory.LiteralExpression( SyntaxKind.TrueLiteralExpression );

搜索了最后一个小时后,我终于想起了此工具.如果有人遇到类似问题,该工具可能会提供帮助.

After searching for the last hour I finally remembered this tool. If anyone has a similar problem that tool might be able to help.

这篇关于在Roslyn(Microsoft CodeAnalysis)中,如何创建布尔文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆