类型为'int'的值不能用作默认参数,因为没有标准转换来键入C#

use*_*484 3 c#

"类型'int'的值不能用作默认参数,因为没有标准转换来键入'Reality.Game.Rooms.RoomActorType'"我的C#.exe中出现了错误.

错误的行:

 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;
   }
Run Code Online (Sandbox Code Playgroud)

这是现实>游戏>房间> RoomActorType.cs:

namespace Reality.Game.Rooms
{
using System;

public enum RoomActorType
  {
    AiBot = 2,
    UserCharacter = 1,
  }
}
Run Code Online (Sandbox Code Playgroud)

谢谢!

gza*_*axx 6

更改方法签名:

public RoomActor GetActorByReferenceId(int ReferenceId, RoomActorType ReferenceType = RoomActorType.UserCharacter)
Run Code Online (Sandbox Code Playgroud)