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

11. Which of the following statements are correct about the String Class in C#.NET?     Two strings can be concatenated by using an expression of the form s3 = s1 + s2;     String is a primitive in C#.NET.     A string built using StringBuilder Class is Mutable.     A string built using String Class is Immutable.     Two strings can be concatenated by using an expression of the form s3 = s1&s2;

  • 1, 2, 5
  • 2, 4
  • 1, 3, 4
  • 3, 5
Show Answer Report

12. Which of the following statements are correct?    1.    String is a value type.     2.    String literals can contain any character literal including escape sequences.     3.    The equality operators are defined to compare the values of string objects as well as     references. 4.        Attempting to access a character that is outside the bounds of the string results in an         IndexOutOfRangeException. 5.        The contents of a string object can be changed after the object is created.

  • 1, 3
  • 3, 5
  • 2, 4
  • 1, 2, 4
Show Answer Report

13. Which method is used to convert a string to uppercase in C#?

  • ToUpper()
  • ToUpperCase()
  • Upper()
  • ConvertToUpper()
Show Answer Report

14. What property of the String class returns the number of characters in the string?

  • Length
  • Size
  • Count
  • Chars
Show Answer Report

15. Which method is used to check if a string contains a specified substring?

  • Contains()
  • Has()
  • Includes()
  • Find()
Show Answer Report

16. What does the String.Compare() method return when two strings are equal?

  • 0
  • 1
  • true
  • false
Show Answer Report

17. Which method removes all leading and trailing white-space characters from a string?

  • Trim()
  • Strip()
  • Clean()
  • RemoveSpaces()
Show Answer Report

18. How do you concatenate two strings in C#?

  • Using + operator
  • Using & operator
  • Using concat() method
  • Using join() method
Show Answer Report

19. Which method splits a string into substrings based on specified delimiters?

  • Split()
  • Divide()
  • Separate()
  • Partition()
Show Answer Report

20. What is the result of "Hello".Substring(1, 3)?

  • ell
  • Hel
  • ello
  • ell
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test