Reflection in csharp
what is Reflection?whenever we use that Reflection in application?...
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Manikavelu VelayuthamRank #413 · 6K reputationPosted Sep 30, 2010, 1:37 AM EDT
So to know the indepth of that assembly, reflection is used.
Through reflection you can iterate all the properties, methods, or events available in it.
Eg:-
string sAssemblyName = GetValidAssembly(args);
Assembly assem = Assembly.LoadFrom(sAssemblyName);
Type[] types = assem.GetTypes();
foreach (Type t in types)
{
try
{
Console.WriteLine("Type information for:" + t.FullName);
Console.WriteLine("\tBase class = " + t.BaseType.FullName);
Console.WriteLine("\tIs Class = " + t.IsClass);
Console.WriteLine("\tIs Enum = " + t.IsEnum);
Console.WriteLine("\tAttributes = " + t.Attributes);
}
Sam HobbsRank #107 · 20.5K reputationPosted Sep 30, 2010, 2:26 PM EDT