How to remove lowercase on a textbox?

后端 未结 11 1871
难免孤独
难免孤独 2020-12-31 02:47

I\'m trying to remove the lower case letters on a TextBox..

For example, short alpha code representing the insurance (e.g., \'BCBS\' for \'Blue Cross B

11条回答
  •  余生分开走
    2020-12-31 03:39

    I´d map the value to your abbreviation in a dictionary like:

    Dictionary valueMap = new Dictionary();
    valueMap.Add("Blue Cross Blue Shield", "BCBS");
    
    string Code = "";
    if(valueMap.ContainsKey(txtDesc.Text))
      Code = valueMap[txtDesc.Text];
    else
      // Handle
    

    But if you still want the functionality you mention use linq:

    string newString = new string(txtDesc.Text.Where(c => char.IsUpper(c).ToArray());
    

提交回复
热议问题