What is the best way to implement dynamic property in a C# object?
<p>I have a number of class objects, each of which needs a URL field which is always formatted in the same way via parameter <code>TypeId</code>, another property of the class.</p>

<p>What is the best way to abstract this as a dynamic property so the URL field is generated based on the <code>TypeId</code> and <code>ItemId</code> properties from the class.</p>

<p>I can think of many ways to do this but wondered what the recommended practice was.</p>

<p><strong>Example below:</strong></p>

<pre><code>public class MyObject
{
    public int Id { get; set; }
    public string URL
    {
        get
        {
            if (TypeId == 3)
            {
                return "/do/this/" + ItemId;
            }
            if (TypeId == 5)
            {
                return "/do/that/" + ItemId;
            }
            return "#";
        }
    }
    public int ItemId { get; set; }
    public int TypeId { get; set; }
}
</code></pre>
