25 C# Coding Questions – String, Char & StringBuilder (Moderate–High)

Use these questions for assessments or lab practice. Focus on correctness, edge cases, and performance.

STRING-Based Questions

  1. Word Frequency Counter – Count occurrences ignoring case and punctuation.
  2. Longest substring without repeating characters.
  3. Run-length encoding (e.g., "aaabbcccc" → "a3b2c4").
  4. Anagram checker without built-in sort.
  5. Reverse words but not characters.
  6. Remove duplicate characters while preserving order.
  7. Find all palindromic substrings.
  8. Case-insensitive replace without regex.
  9. Email masking ("john.doe@gmail.com" → "j***@gmail.com").
  10. Balanced parentheses validator.

CHAR-Based Questions

  1. Count uppercase, lowercase, digits, spaces, and special characters.
  2. Caesar cipher with shift N.
  3. Most frequent character.
  4. Toggle case using only char APIs.
  5. Remove all digits using char checks.
  6. First non-repeating character.
  7. Password strength validator.
  8. Detect consecutive duplicate characters.

STRINGBUILDER / Performance Questions

  1. Reverse a very large string using StringBuilder.
  2. Insert '*' between every two characters.
  3. Remove vowels efficiently.
  4. Compress multiple spaces into one.
  5. Build CSV from a list of objects.
  6. HTML escaper for <, >, &, and quotes.
  7. Log formatter using StringBuilder.