Splitting CamelCase

前端 未结 15 2467
盖世英雄少女心
盖世英雄少女心 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

    If C# 3.0 is an option you can use the following one-liner to do the job:

    
    Regex.Matches(YOUR_ENUM_VALUE_NAME, "[A-Z][a-z]+").OfType().Select(match => match.Value).Aggregate((acc, b) => acc + " " + b).TrimStart(' ');
    

提交回复
热议问题