Is there a better way to create acronym from upper letters in C#?

后端 未结 6 1490
日久生厌
日久生厌 2021-01-19 00:06

What is the best way to create acronym from upper letters in C#?

Example:

Alfa_BetaGameDelta_Epsilon

Expected r

6条回答
  •  执念已碎
    2021-01-19 00:57

    You can use the Where method to filter out the upper case characters, and the Char.IsUpper method can be used as a delegate directly without a lambda expression. You can create the resulting string from an array of characters:

    string abbreviation = new String(enumTypeName.Where(Char.IsUpper).ToArray());
    

提交回复
热议问题