views:

33

answers:

3

Hi, it seems there are no delegates to properties. Is there a convenient way to do the following?

Assert.Throws<InvalidOperationException>(
       delegate
       {
           // Current is a property as we all know
           nullNodeList.GetEnumerator().Current;
       });
A: 

why not say:

Assert.Throws<InvalidOperationException>(
    () => nullNodeList.GetEnumerator().Current);
sukru
im working with c# 2.0 :/
atamanroman
+1  A: 
Assert.Throws<InvalidOperationException>(
    delegate { object current = nullNodeList.GetEnumerator().Current; });
Anton Gogolev
thank you very much. this was easy (but not very intuitive)
atamanroman
+1  A: 

You could try assigning it to a variable or try enumerating:

Assert.Throws<InvalidOperationException>(delegate
{
    // Current is a property as we all know
    object current = nullNodeList.GetEnumerator().Current;
});
Darin Dimitrov