mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-06 14:53:47 +00:00
Initial commit
This commit is contained in:
parent
d5bde3c775
commit
5fb8e6929b
33 changed files with 842 additions and 0 deletions
34
vs4win/Chapter02/Vocabulary/Program.cs
Normal file
34
vs4win/Chapter02/Vocabulary/Program.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System.Reflection;
|
||||
|
||||
// declare some unused variables using types
|
||||
// in additional assemblies
|
||||
System.Data.DataSet ds;
|
||||
HttpClient client;
|
||||
|
||||
Assembly? myApp = Assembly.GetEntryAssembly();
|
||||
|
||||
if (myApp == null) return; // quit the app
|
||||
|
||||
// loop through the assemblies that my app references
|
||||
foreach (AssemblyName name in myApp.GetReferencedAssemblies())
|
||||
{
|
||||
// load the assembly so we can read its details
|
||||
Assembly a = Assembly.Load(name);
|
||||
|
||||
// declare a variable to count the number of methods
|
||||
int methodCount = 0;
|
||||
|
||||
// loop through all the types in the assembly
|
||||
foreach (TypeInfo t in a.DefinedTypes)
|
||||
{
|
||||
// add up the counts of methods
|
||||
methodCount += t.GetMethods().Count();
|
||||
}
|
||||
|
||||
// output the count of types and their methods
|
||||
Console.WriteLine(
|
||||
"{0:N0} types with {1:N0} methods in {2} assembly.",
|
||||
arg0: a.DefinedTypes.Count(),
|
||||
arg1: methodCount,
|
||||
arg2: name.Name);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue