I was trying to create a method to find the amount of duplicate characters in a string. So, for example,
public static int DuplicateCount(string str)
int buffer = new int; //128 possible ASCII characters
string lower = str.ToLower();
int dups = 0;
for (int i = 0; i < str.Length; i++)
int num = (int)str[i];
if (buffer[num] == 2)
This happens because you used
str instead of
lower in your loop.
ToLower() only returns a copy of a modified string (which you obviously saved, but didn't use).