c# - how to make string type nullable -


i want make middle name of person optional. have been using c#.net code first approach. integer data type easy using "?" operator make in nullable. looking way make sting variable nullable. tried search not find way make nullable.

below code. please suggest me how make nullable.

public class childreninfo {     [key]     public int chidrenid { get; set; }      [required]     [display(name ="first name")]     [stringlength(50,errormessage ="first name cannot exceed more 50 characters")]     [regularexpression(@"^[a-z]+[a-z]*$",errormessage ="name cannot have special character,numbers or space")]     [column("fname")]     public string cfname { get; set; }      [display(name ="middle name")]     [regularexpression(@"^[a-z]+[a-z]*$",errormessage ="middle name cannot have special character,numbers or space")]     [stringlength(35,errormessage ="middle name cannot have more 35 characters")]     [column("mname")]     public string? cmname { get; set; }      }    

string reference type , nullable, don't need special. specifying type nullable necessary value types.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -