I am using the Visio API to loop through each Microsoft.Office.Interop.Visio.Master
object in a Microsoft.Office.Interop.Document
's Masters
collection.
When I use var
as follows, the compiler only recognizes master
as type object
and throws an error:
foreach (var master in doc.Masters)
Instead, I have to do this for it to work:
foreach (Visio.Master master in doc.Masters)
Why is this happening? Usually I have no problems using var
in a foreach loop.
Edit: the error I get when I use the Open
method on master
is:
'object' does not contain a definition for 'Open' and no extension method 'Open' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)