title: Passing object parameter to WCF
body: <p>DataContract as :-</p>
  
  <pre><code>namespace AssemblyA
  {
      public class Person                                 
      {     
          public string FirstName {get;set;}
          public string LastName {get;set;}                             
      }                                                              
  }
  </code></pre>
  
  <p>Service is as follows:-</p>
  
  <pre><code>[ServiceContract]            
  public interface IServer      
  { 
      [OperationContract]  
      Person GetPerson(); 
  
      [OperationContract] 
      Person UpdatePerson( Person person )             
  }
  </code></pre>
  
  <p>Client side:-</p>
  
  <pre><code>using AssemblyA; 
  
  namespace AssemblyB 
  {
      class Program     
      {         
          static void Main(string[] args)         
          {             
              IServer server = factory.CreateChannel(); 
              Person person = server.GetPerson(); 
              person.FirstName = "Kilroy";       
              person.LastName = "";
              Person p = server.UpdatePerson(person);
              String str = p.LastName; 
          }    
      }
  } 
  </code></pre>
  
  <p>I have two problems:-</p>
  
  <ol>
  <li><p>I am setting LastName property to blank and called GetPerson method. After that when I am checking for LastName property it is coming as nothing instead of blank.</p></li>
  <li><p>Second Problem is if I made change in Person class as follows:-</p>
  
  <pre><code>public class Person                                             
  {                                                 
      String _FirstName;   
      String _LastName;                                 
      public string FirstName 
      {
          get{}
          set
          { 
              _FirstName=value;
              _LastName="XYZ";
          }
      }
  
      public string LastName { get;set; }  
  }  
  </code></pre></li>
  </ol>
  
  <p>After this I Changed my Client as :-</p>
  
  <pre><code>IServer server = factory.CreateChannel(); 
  Person person = server.GetPerson(); 
  person.FirstName = "Kilroy";       
  person.LastName = "abc";
  Person p = server.UpdatePerson(person);
  String str = p.LastName; 
  </code></pre>
  
  <p>then in str it shows "XYZ" instead of "abc". But I am expecting "abc" from it.</p>
  
  <p>Please advice as I have to use it in my project.</p>