title: Mapping a SharePoint list item to a C# class
body: <p>Say I have:</p>
  
  <pre><code>public class SPListItem
  { 
       public override object this[string fieldName]
       {
         get
         {
           return this.GetValue(fieldName);
         }
         set
         {
           this.SetValue(fieldName, value, !this.HasExternalDataSource);
         }
       }
  }
  
  public class Bar
  {
      public int Prop1 { get; set; } 
      public int Prop2 { get; set; } 
      public int Prop3 { get; set; } 
  }
  </code></pre>
  
  <p>is there any way I can do:</p>
  
  <pre><code>var fooInst = new SPListItem();
  Bar barInst = (Bar)fooInst // or maybe Bar.FromFoo(Foo f) if handling the cast is not possible
  </code></pre>
  
  <p>and then have: </p>
  
  <p><code>barInst.Prop1</code> give me the equivalent of:</p>
  
  <p><code>fooInst["Prop"];</code></p>
  
  <p>Without implementing the getters and setters for every property in Bar?</p>