Splitting CamelCase

前端 未结 15 2461
盖世英雄少女心
盖世英雄少女心 2020-12-07 10:56

This is all asp.net c#.

I have an enum

public enum ControlSelectionType 
{
    NotApplicable = 1,
    SingleSelectRadioButtons = 2,
    SingleSelectD         


        
15条回答
  •  太阳男子
    2020-12-07 11:39

    Tillito's answer does not handle strings already containing spaces well, or Acronyms. This fixes it:

    public static string SplitCamelCase(string input)
    {
        return Regex.Replace(input, "(?<=[a-z])([A-Z])", " $1", RegexOptions.Compiled);
    }
    

提交回复
热议问题