小编One*_*way的帖子

C#List <T> .Find(x => x.Rectangle.Contains(Point))FAIL

对于我的生活,我无法理解为什么这段代码会产生以下输出...

我认为当使用List和lambda时,如果类型公开了一个Rectangle属性并使用了矩形对象的Contains方法,那么就会有一个bug或者什么......当List Find方法失败时,显式迭代证明是真的....

单程

public GridSquare WorldToKeyPadSub(Point location)
    {
        location = _Map.WorldToClient(location);
        GridSquare gs = this.Find(x => x.Rectangle.Contains(location));
        GridSquare kp = gs.Find(x => x.Rectangle.Contains(location));
        List<GridSquare> list = kp.FindAll(x=>x.Rectangle.Contains(location));
        u.dp(list.Count);
        GridSquare sub = kp.Find(x => x.Rectangle.Contains(location));

        if (sub == null)
        {
            u.dp("Location to look for " + location);
            u.dp("Found Location in grid square " + gs.ToString());
            u.dp("grid square bounds " + gs.Rectangle.ToString());
            u.dp("Found Location in Keypad " + kp.ToString());
            u.dp("key pad bounds " + kp.Rectangle.ToString());
            u.dp("Sub Key Pads Print All …
Run Code Online (Sandbox Code Playgroud)

.net contains point

3
推荐指数
1
解决办法
3450
查看次数

标签 统计

.net ×1

contains ×1

point ×1