C# find properties
What is the process to find the properties in c#?
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
Posted Jul 9, 2012, 2:11 AM EDT
PropertyInfo[] propertyInfos = typeof(YourClassName).GetProperties();
// writes all the property names
foreach (PropertyInfo propertyInfo in propertyInfos)
{
Console.WriteLine(propertyInfo.Name);
}
Hope this helps you.
VulpesRank #55 · 29.2K reputationPosted Jul 9, 2012, 2:22 AM EDT
The example also shows how to include static properties and non-public properties in the list:
The output should be: