fork download
// public domain
using System;
using System.Collections.Generic;
using System.Linq;

public static class PropertyEnumerator {
    public static IEnumerable<object> EnumerateProperties<T>(T instance)
        => typeof(T).GetProperties().Select(prop => prop.GetValue(instance));
}

public class Test {
    public int A { get; set; }
    public string B { get; set; }
    public double C { get; set; }
}

public class Program {
    public static void Main() {
        var test = new Test { A = 5, B = "hoge", C = 3.14 };
        foreach (var prop in PropertyEnumerator.EnumerateProperties(test)) {
            Console.WriteLine(prop);
        }
    }
}
Success #stdin #stdout 0.03s 15916KB
stdin
Standard input is empty
stdout
5
hoge
3.14