C Sharp Strings Questions and Answers

Take Exam

C# Strings are one of the most important topics in programming interviews and technical tests. This page features C# programming questions and answers focused on string manipulation, methods, immutability, and performance optimization. These C# strings questions with answers are ideal for students preparing for TCS, Infosys, Wipro, and Capgemini placement exams. Understanding string operations in C# helps programmers efficiently manage text data and avoid common pitfalls related to memory and performance.

C Sharp Strings

Showing 10 of 32 questions

21. Which method replaces all occurrences of a specified character in a string?

  • Replace()
  • Change()
  • Substitute()
  • Swap()
Show Answer Report

22. What does String.IsNullOrEmpty() check for?

  • Null or empty string
  • Null or whitespace
  • Empty or whitespace
  • Null or zero length
Show Answer Report

23. Which method converts a string to lowercase?

  • ToLower()
  • ToLowerCase()
  • Lower()
  • ConvertToLower()
Show Answer Report

24. What is the purpose of String.Format() method?

  • Format strings
  • Compare strings
  • Concatenate strings
  • Search strings
Show Answer Report

25. Which method checks if a string starts with a specified substring?

  • StartsWith()
  • BeginsWith()
  • StartWith()
  • HasPrefix()
Show Answer Report

26. What does "Hello".IndexOf("l") return?

  • 2
  • 1
  • 3
  • 0
Show Answer Report

27. Which method creates a new string by repeating a character multiple times?

  • new String("c", 5)
  • String.Repeat("c", 5)
  • String.Fill("c", 5)
  • String.Create("c", 5)
Show Answer Report

28. What is string interpolation in C#?

  • Embed expressions in strings
  • Compare strings
  • Convert strings
  • Encrypt strings
Show Answer Report

29. Which method removes a specified number of characters from a string?

  • Remove()
  • Delete()
  • Cut()
  • Erase()
Show Answer Report

30. What is the difference between String and StringBuilder?

  • String is immutable
  • String is faster
  • StringBuilder is immutable
  • No difference
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test