Duncan Lithgow

Duncan Lithgow

  • NA
  • 5
  • 1.1k

Is 'e' a method, a property or what?

Mar 5 2014 4:05 AM
In a piece of code as below what is 'e'? I thought that in C# all variables have to be declared, so it isn't a variable. Is 'e' a member of the Element class ( a property) ? I don't understand what is is or how it knows what it is... I don't see it being declared ... have I missed the lesson about how to declare a new method?

foreach (Element e in new FilteredElementCollector(doc)
        .OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_Doors))
 {
         FamilyInstance fi = e as FamilyInstance;
         FamilySymbol fs = fi.Symbol;
         Family family = fs.Family;
         info += family.Name + ": " + fs.Name + ": " + fi.Name + Environment.NewLine;
 }

I appreciate that this is a beginner question, but I don't know where to look to fully understand this code.

And how is fi being declared, what type is it, and how does it know what type it is?

(this code uses the Autodesk Revit API)

Answers (3)