title: How force a maximum string length in a C# web service object property?
body: <p>In this class for example, I want to force a limit of characters the first/last name can allow.</p>
  
  <pre><code>public class Person
  {
       public string FirstName { get; set; }
       public string LastName { get; set; }
  }
  </code></pre>
  
  <p>Is there a way to force the string limit restriction for the first or last name, so <strong>when the client serializes this</strong> before sending it to me, it would throw an error on their side if it violates the lenght restriction?</p>
  
  <p>Update: this needs to be identified and forced in the WSDL itself, and not after I've recieved the invalid data.</p>