c# - skip white space by reading characters -
i want skip white space between characters. example, have this:
abc def ghi
, output has be:
a = 1 b = 1 c = 1..etc
but get:
"" = 2.
because there 2 white spaces between characters.
i try this:
sorteddictionary<char, int> dictionary = new sorteddictionary<char, int>(); console.writeline("enter string: "); // prompt user input string input = console.readline(); // input // split input text tokens char[] letters = regex.split(input.tochararray().tostring(), @"\s+");
just omit spaces array:
using system.linq; // other code char[] letters = input.where(c => c != ' ').toarray();
a string inherently char
array, don't need cast call.
Comments
Post a Comment