How to fetch parameter values from created object?

Im currently playing around with an app where i need to read all parameter values(which already are only strings) from a created object, into a single string. How would one go about doing this?

I need to read from one of these objects thats already created, all its parameters it was created with.

Here is the constructor for the object thats being created:

    public aTableRow(string newProduct, string newPrice, string newStartDate, string newEndDate, string newWhere, string newNote, string newTippedBy)
    {
        product = newProduct;
        price = newPrice;
        startDate = newStartDate;
        endDate = newEndDate;
        where = newWhere;
        note = newNote;
        tippedBy = newTippedBy;
    }

Properties

public double Price
{
  get { return price; }
  set { price = value; }
}

and if you want for say price to be set in the constructor and never changed, just never define that set line. Leave it as a public property with get that returns the field price.

Look into properties more you will see auto implemented properties.

public double Price { get; set; }

And now you can in your constructor do Price = newPrice. Access it by class.Price etc.

Thats one way to do it i guess, just thougth there might be some fancy way to do it :stuck_out_tongue: Thx though!

If you mean display all the params into one string (as you said you need to read all params values into a single string is a little ambiguous) for an easier debug (adding a watch to hte object when stopping is a little better)
You could define a ToString() method in your class, in which you build your own string as you want it to be displayed

public string ToString()
{
string tmp = String.Empty;
//concat as you wish into tmp for ex, or use a stringbuilder if you have many params
tmp = String.Format(“product= {0}\nprice= {1}\n”, this.product, this.price);
return tmp;
}

If you mean convert from strings to int, float etc, you can do a Convert.x or use the type (ex int.TryParse or int.Parse)