Return to Snippet

Revision: 24371
at February 28, 2010 17:48 by rtipton


Initial Code
using System;
using System.Reflection;

class Program
{
    static void Main(string[] args)
    {
        var person = new Person 
            { Name = "Rhonda", 
              FaveShow = "Fringe, Lost", 
              FaveMovie = "Star Trek", 
              FaveSong = "Contagious" };

        var type = typeof(Person);
        var properties = type.GetProperties();

        foreach (PropertyInfo property in properties)
        {
            Console.WriteLine("{0} : {1}", property.Name, property.GetValue(person, null));
        }

        Console.Read();
    }
}

public class Person
{
    public string Name { get; set; }
    public string FaveShow { get; set; }
    public string FaveMovie { get; set; }
    public string FaveSong { get; set; }
}

Initial URL


Initial Description


Initial Title
GetProperties()

Initial Tags


Initial Language
C#