Weird Types when retrieving all Types from Assembly

Viewed 22

I use reflection to retrieve Types from within a namespace and do some stuff which each of them:

Type baseType = typeof(BaseUpdate);
            var updateTypes = baseType.Assembly.GetTypes(); 
foreach (var type in updateTypes) {
  if (type.Namespace!="myApp.Logic.Updates") continue;
  // stuff
}

This works fine. I retrieve all the types I want and can do stuff with them. But as an addition I also retrieve some "weird" types I do not really understand where they come from. They all start with "<>" and seem to have the "IsNestedPrivate" - Flag set to true: enter image description here That flag helps me to differenciate those types but what are those and why are they there?

1 Answers

These are classes the compiler has generated behind the scenes to implement functionality like lambda functions, IEnumerable functionality (via the yield keyword) and async/await state machines.

Chances are if you look at the attributes on the type then one will be CompilerGenerated

Related