Function that accepts an Object with "Width"
<p>I want to create function that accepts an object that has definition <code>Width</code>  </p>

<p>My try;</p>

<pre><code>Int32 getWidth(object obj)
{
    return obj.Width;
}
</code></pre>

<p>This will fail, because <code>obj</code> doesn't have definition width.</p>

<p>-- More details --</p>

<p>The usage of the function could be..</p>

<p>// a button<br>
<code>button1 = System.windows...Button();</code></p>

<p>// getting the width of a button.<br>
<code>int width = getWidth(button1);</code></p>

<p>The idea here that it function getWidth should work for object that has <code>Width</code> properity such as buttons, lables, checkboxes, ....</p>