C Sharp Strings Questions and Answers
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()
22. What does String.IsNullOrEmpty() check for?
- Null or empty string
- Null or whitespace
- Empty or whitespace
- Null or zero length
23. Which method converts a string to lowercase?
- ToLower()
- ToLowerCase()
- Lower()
- ConvertToLower()
24. What is the purpose of String.Format() method?
- Format strings
- Compare strings
- Concatenate strings
- Search strings
25. Which method checks if a string starts with a specified substring?
- StartsWith()
- BeginsWith()
- StartWith()
- HasPrefix()
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)
28. What is string interpolation in C#?
- Embed expressions in strings
- Compare strings
- Convert strings
- Encrypt strings
29. Which method removes a specified number of characters from a string?
- Remove()
- Delete()
- Cut()
- Erase()
30. What is the difference between String and StringBuilder?
- String is immutable
- String is faster
- StringBuilder is immutable
- No difference