by
0
5
154k
0
Top 1% !
Pearl of Wisdom
Easy-to-find
Specified
OpenSource
Popularity: 12406th place

Published on:

LanguageCSharp
LicenseMIT_X11
OSWindows

GetHotkeyAndLabel: Parse a string containing a hotkey character.           Take a string of the form              Yes to &all           and returns a two-dimensional array split out as              "A", "Yes to all".

<summary>
Parse a string containing a hotkey character.
Take a string of the form
   Yes to &amp;all
and returns a two-dimensional array split out as
   "A", "Yes to all".
</summary>
<param name="input">The string to process</param>
<returns>
A two dimensional array containing the parsed components.
</returns>
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/287278/GetHotkeyAndLabel--Parse-a-string-contai?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
/// <summary> /// Parse a string containing a hotkey character. /// Take a string of the form /// Yes to &amp;all /// and returns a two-dimensional array split out as /// "A", "Yes to all". /// </summary> /// <param name="input">The string to process</param> /// <returns> /// A two dimensional array containing the parsed components. /// </returns> private static string[] GetHotkeyAndLabel(string input) { string[] result = new string[] { String.Empty, String.Empty }; string[] fragments = input.Split('&'); if (fragments.Length == 2) { if (fragments[1].Length > 0) { result[0] = fragments[1][0].ToString(). ToUpper(CultureInfo.CurrentCulture); } result[1] = (fragments[0] + fragments[1]).Trim(); } else { result[1] = input; } return result; }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus