引言:最近在工作中遇到与某些API对接的post的数据需要将对象的字段首字母小写.解决办法有两种:第一种:使用对象的字段属性设置JsonProperty来实现(不推荐,因为需要手动的修改每个字段的属性) public class UserInfo { [JsonProperty("id")] public int Id{ set; get; } [JsonProperty("userName")] public string UserName{ set; get;
//将edit1中的每个字符串改为首字母大写 procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);begin with Sender as Tedit do if (text = '') or (text[selstart] = ' ') or ( sellength = length( text ) )then if Key in ['a'..'z'] then Key := Upcase(Key)