Skip to content

Unable to cast object of type 'Int32' to type 'Dictionary`2'. #771

@hui1993

Description

@hui1993

偶现的类型转换错误

代码如下:
public bool TryGetItem(Hex hex, out T item)
{
var key = GetHexkey(hex);
if(_map.ContainsKey(key))
{
item = _map[key];
return true;
}
item = default;
return false;
}

_map是dictionary

可能跟范型有关,准备去掉试试

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions