[英]Cannot implicitly convert 'void' to 'bool'
In the code snippet below, this line: 在下面的代码段中,此行:
if (player.Manager.Chat.Say(plr, user))
Results in an error: 导致错误:
Cannot implicitly convert 'void' to 'bool'
无法将“ void”隐式转换为“ bool”
Why am I getting this error? 为什么会出现此错误?
internal class AFKCommand : Command
{
private AFKCommand() : base("afk", 0) { }
protected override bool Process(Player player, RealmTime time, string[] args)
{
string user = player.Client.Account.Name;
var plr = player.Manager.FindPlayer(user);
if (args.Length == 0)
{
if (args[0] == "on")
{
if (player.Manager.Chat.Say(plr, user))
{
plr.Manager.Chat.Say(plr, "I am AFK at the moment. This message was sent using the AFK feature. Type /afk for info");
}
}
}
return true;
}
}
If you want text to mean something then you can either make an enumeration 如果您想让文字表示某些含义,则可以进行枚举
enum Test
{
A,
B
}
Then use Test.A
or Test.A.ToString()
然后使用
Test.A
或Test.A.ToString()
or use a SortedList where you can store your results. 或使用SortedList来存储结果。
I don't however completely understand your question. 但是,我不完全理解您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.