Is it possible to list our all the string variable names and values out

Is is possible to list our the variable names from the instance and it value.

  public class Car
  {
    public string Color;
    public string Model;
    public string Made;
  }

  protected void Page_Load(object sender, EventArgs e)
  {

//Create new instance
    Car MyCar = new Car();
    MyCar.Color = "Red";
    MyCar.Model = "NISSAN";
    MyCar.Made = "Japan";

//SOMETHING HERE
    foreach (MyCar Variable in MyCar)
    {
      Response.Write("<br/>Variable Name"+  "XXX"+ "Variable Value");
    }

}
8
задан Erick Petrucelli 7 May 2011 в 16:56
поделиться