CSharp · Console
using System;
using System.Linq;
public class Program
{
class Parent {
public int P1 { get; set; }
}
class Child : Parent {
public int P2 { get; set; }
}
public static void Main() {
foreach (string name in GetProps(new Child())) {
Console.WriteLine(name);
}
}
static string[] GetProps(Parent p) {
return p.GetType().GetProperties().Select(prop => prop.Name).ToArray();
}
}