title: .NET: Is there a String.Format form for inserting the value of an object property into a string?
body: <p>I think the direct answer to the question is 'No' but I'm hoping that someone has written a real simple library to do this (or I can do it...ugh...)</p>
  
  <p>Let me demonstrate what I am looking for with an example.
  Suppose I had the following:</p>
  
  <pre><code>class Person {
    string Name {get; set;}
    int NumberOfCats {get; set;}
    DateTime TimeTheyWillDie {get; set;}
  }
  </code></pre>
  
  <p>I would like to be able to do something like this:</p>
  
  <pre><code>static void Main() {
    var p1 = new Person() {Name="John", NumberOfCats=0, TimeTheyWillDie=DateTime.Today};
    var p2 = new Person() {Name="Mary", NumberOfCats=50, TimeTheyWIllDie=DateTime.Max};
  
    var str = String.Format(
  
  "{0:Name} has {0:NumberOfCats} cats and {1:Name} has {1:NumberOfCats} cats.  They will die {0:TimeTheyWillDie} and {1:TimeTheyWillDie} respectively
  ", p1, p2);
  
    Console.WriteLine(str);
  }
  </code></pre>
  
  <p>Does anyone know if theres a format for doing something like this or if someone has written a library to do it?  I know it shouldn't be too hard, but I'd rather not be reimplementing the wheel.</p>