Oren (Ayende) wrote a cool little script in Boo showing how to count the number of types and methods in mscorlib. Just for fun, here's an equivalent script in PowerShell that does the same thing:

[System.Object].Assembly.GetTypes() | foreach { 
   $typeCount++ 
   $methodCount += $_.GetMethods().Length
}
"Types $typeCount, Methods $methodCount"

This is, of course, just one possible way to write it.

Technorati tags: ,


Tomas Restrepo

Software developer located in Colombia. Sr. PFE at Microsoft.