c# - Is it possible to split a full name selected in a dropdown list and save it into 2 separate columns as first name and last name? -


i have following columns in entity framework code first approach:

public string lastname { get; set; } public string firstname { get; set; } 

and combine them full name:

 public string fullname     {         { return lastname + " " + firstname; }     } 

i don't know if it's possible, how can generate setter in order send values fullname other 2 columns when selecting e.g dropdown list?

say fullname.split(' '); getting array of names. it's when first , last names single word. how john billy doe? lastname end , firstname begin?

instead, use different separator, comma: john, billy doe. way, doing fullname.split(','); yield correct last name , first name.

public string fullname {         {          return lastname + ", " + firstname;     }     set     {          string[] names = value.split(", ");          lastname = names[0];          firstname = names[1];     } } 

edit: of course, validation required value, it's pretty hard type code on android app (as doing). so, unless need that, leave you.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -