0

我对List<T>其中 T 是自定义类的 linq 方法有疑问。

这是我的课:

public class RoomWorkingPlan
{
        public Int64 m_IdRoom;
        public Dictionary<DateTime, List<WorkInterval>> workingPlan = new Dictionary<DateTime, List<WorkInterval>>();
}

我正在尝试使用任何方法或在这样的列表中选择:

List<RoomWorkingPlan> roomsworking = (List<RoomWorkingPlan>)m_RoomAvailable.Values.Cast<RoomWorkingPlan>().ToList();
DateTime startingDate = DateTime.now;

if (!roomsworking.Any<RoomWorkingPlan>(r => r.workingPlan.ContainsKey(startingDate)))
{
    return false;
}

但我收到一条错误消息,说“表达式不能包含 Lambda 表达式”。有任何想法吗?在http://msdn.microsoft.com上,所有示例都包含 Lamda 表达式。

编辑:m_RoomAvailable 是一个哈希表,包含一个 int64 作为键和 RoomWorkingPlan 作为值。

4

1 回答 1

0

You try to run lambda from the Quick Watch window (Controllo immediato, from your snapshot in your comment) in Visual Studio. Lambda expressions cannot be evaluated in this window : this is a limitation of Visual Studio. Lambda can only be evaluated in code at runtime.

It is also true for the Watch, Locals and Immediate windows.

If you want to debug lambdas, you have to use breakpoints in your code. Note you'll only have access to your functors (predicates, selectors...) and the result.

For more informations : Visual Studio debugging "quick watch" tool and lambda expressions

于 2013-04-03T15:00:18.637 回答