String_Quiz.md - brainchildservices/curriculum GitHub Wiki

  1. What is C# String?

  • In C#, a string is a series of characters that is used to represent text. It can be a character, a word or a long passage surrounded with the double quotes ". C# provides the String data type to store string literals. 2.### Guess which one is right?
  1. string s='anand';
  2. string s="anand";
  3. string s=anand;
  • Answer: string s="anand";
  1. What is String Length?

    • Returns the number of characters in a string
  2. String s="i am";

    int m=s.length;

    1. 4
    2. 2
    3. 3
    4. 0
    • _Ans:1
  3. What do you mean by String Concatenation?

    • The + operator can be used between strings to combine them. This is called concatenation.
  4. What is String Interpolation?

    • Another option of string concatenation, is string interpolation, which substitutes values of variables into placeholders in a string.
  5. What is String.Format?

    • String.Format() method formats strings in a desired format by inserting objects and variables with specified space and alignments into another strings and literals. It is also often used to format strings into specific formats.
  6. How to access each character of a string?

    • You can access the characters in a string by referring to its index number inside square brackets [].
  7. What are escape characters?

    • An escape sequence in C language is a sequence of characters that doesn't represent itself when used inside string literal or character.
  8. Examples for escape characters

       \b	         -                  Backspace
       \f	          -                 Form Feed
       \n	           -                New Line
       \r	            -            Carriage Return