Applying a function to every field in a class
<p>This is an interesting concept which i couldn't figure out how to implement. (its related to a university assignment where i need to deploy the decorator pattern).</p>

<p>I've written rough C# code below which won't compile however, Suppose, i have a class</p>

<pre><code>Class A {
   public int A { get; set; }
   public string B { get; set; }
   public float C { get; set; }

   public string concatFields() {
       string sample = null;
       foreach (Field f in this) {
           sample += f.ToString();
       }
       return sample;
   }
}
</code></pre>

<p>How in terms would you achieve the concatFields method? Is there a way to iterate through the class's fields (without knowing the names of the fields) and call ToString() on each.</p>

<p>In example B scenario, how would you apply the same method on all Fields provided they were the same type.</p>

<p>Cheers guys for the help, i've tagged this with C# but not sure what other tags could be applied</p>
