Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get list of the classes in casual assembly
Message
From
16/03/2010 10:35:46
 
 
To
16/03/2010 09:52:04
Vladimir Zhuravlev
Institute of the Physics of Earth,Russia
Moscow Region, Russia
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01453908
Message ID:
01454781
Views:
31
Vlad,

The code below (your code) works

As to intellisense and where - see image attached
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Reflection;

namespace BaseTest
{
	class test3
	{


		//______________________________________________________________________
		static void Main()
		{
			string assemblyName = "BaseTest";
			var xx = GetModInfo(assemblyName);
			Console.WriteLine("{0}", xx.Length);
			Console.ReadLine();
		}

		//______________________________________________________________________

		//______________________________________________________________________

		public static string GetModInfo(string Assemblyname)
		{
			string vbTab = "   ";


			var assembly = Assembly.Load(Assemblyname);
			List<Type> classList = new List<Type>();

			foreach (var module in assembly.GetModules())
			{
				classList.AddRange(from x in module.GetTypes().Where(x => x.IsClass) select x);
			}

			foreach (var className in classList)
			{
				vbTab = vbTab + className.Name;
			}

			return vbTab;
		}


	}

}
Some remarks

(1) I would return a list of classes instead of a string

(2) If you insist on using a string, consider using StringBuilder()
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform