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
Post a Comment