C# Programming - Strings

Exercise : Strings - General Questions
  • Strings - General Questions
6.
If s1 and s2 are references to two strings, then which of the following is the correct way to compare the two references?
s1 is s2
s1 = s2
s1 == s2
strcmp(s1, s2)
s1.Equals(s2)
Answer: Option
Explanation:
No answer description is available. Let's discuss.

7.
What will be the output of the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            string str= "Hello World!";
            Console.WriteLine( String.Compare(str, "Hello World?" ).GetType() );
        }
    }
}
0
1
String
Hello World?
System.Int32
Answer: Option
Explanation:
No answer description is available. Let's discuss.

8.
Which of the following snippets are the correct way to convert a Single into a String?
  1. Single f = 9.8f; 
    String s;
    s = (String) (f);
  2. Single f = 9.8f; 
    String s;
    s = Convert.ToString(f);
  3. Single f = 9.8f; 
    String s;
    s = f.ToString();
  4. Single f = 9.8f; 
    String s;
    s = Clnt(f);
  5. Single f = 9.8f; 
    String s;
    s = CString(f);
1, 2
2, 3
1, 3, 5
2, 4
Answer: Option
Explanation:
No answer description is available. Let's discuss.

9.
Which of the following will be the correct output for the C#.NET code snippet given below?
String s1="Kicit";
Console.Write(s1.IndexOf('c') + " "); 
Console.Write(s1.Length);
3 6
2 5
3 5
2 6
3 7
Answer: Option
Explanation:
No answer description is available. Let's discuss.

10.
Which of the following is correct way to convert a String to an int?
  1. String s = "123"; 
    int i;
    i = (int)s;
  2. String s = "123";
    int i;
    i = int.Parse(s);
  3. String s = "123"; 
    int i;
    i = Int32.Parse(s);
  4. String s = "123"; 
    int i;
    i = Convert.ToInt32(s);
  5. String s = "123"; 
    int i;
    i = CInt(s);
1, 3, 5
2, 4
3, 5
2, 3, 4
Answer: Option
Explanation:
No answer description is available. Let's discuss.