title: How can I customise how Razor converts values of certain types to text?
body: <p>Imagine I have some custom type:</p>
  
  <pre><code>public class CustomType
  {
      public override string ToString() {
          return "Default";
      }
  }
  </code></pre>
  
  <p>Next, imagine I use an instance of this type in a Razor view:</p>
  
  <pre><code>@model CustomType
  
  &lt;span&gt;The custom type is @Model&lt;/span&gt;
  </code></pre>
  
  <p>Razor seems to use <code>ToString</code> to convert the value into text for the resulting HTML. However, I want to tell Razor that whenever it wants to format a <code>CustomType</code>, it should use  some given custom formatting logic.</p>
  
  <p>Is this possible? If so, how can I do it?</p>