[英]A value of type 'int' cannot be used as a default parameter because there are no standards conversions to type C#
"A value of type 'int' cannot be used as a default parameter because there are no standards conversions to type 'Reality.Game.Rooms.RoomActorType'" is there error I'm getting within my C#.exe. “类型'int'的值不能用作默认参数,因为没有标准转换来键入'Reality.Game.Rooms.RoomActorType'”我的C#.exe中出现了错误。
The line(s) of error: 错误的行:
public RoomActor GetActorByReferenceId(int ReferenceId, RoomActorType ReferenceType = 1)
{
lock (this.mActors)
{
foreach (RoomActor actor in this.mActors.Values)
{
if ((actor.Type == ReferenceType) && (actor.ReferenceId == ReferenceId)) /* line of error */
{
return actor;
}
}
}
return null;
}
Here's Reality>Game>Rooms>RoomActorType.cs: 这是现实>游戏>房间> RoomActorType.cs:
namespace Reality.Game.Rooms
{
using System;
public enum RoomActorType
{
AiBot = 2,
UserCharacter = 1,
}
}
Thanks! 谢谢!
更改方法签名:
public RoomActor GetActorByReferenceId(int ReferenceId, RoomActorType ReferenceType = RoomActorType.UserCharacter)
RoomActorType ReferenceType = 1)
should be 应该
RoomActorType ReferenceType = RoomActorType.UserCharacter)
or if you really want to use int do: 或者如果你真的想使用int do:
RoomActorType ReferenceType = (RoomActorType)1)
You can not use int as enum without casting 如果没有强制转换,则不能将int用作枚举
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.