C# Programming - Strings - Discussion
Discussion Forum : Strings - General Questions (Q.No. 7)
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() );
}
}
}
Discussion:
14 comments Page 2 of 2.
Mithilesh Singh said:
1 decade ago
String.Compare() returns 0 which is of type System.int32.
Gloops said:
1 decade ago
Taylor, you have a simple way to know the value of an expression : while stopped at a breaking point on the following line, select the expression and depress shift F9 (this is in Visual Studio 2005). This also allows you to add a spy to watch the value dynamically.
I obtain -1, and if I replace the question mark by an exclamation mark to get the same text (and relaunch the application), I obtain 0.
I obtain -1, and if I replace the question mark by an exclamation mark to get the same text (and relaunch the application), I obtain 0.
Suresh said:
10 years ago
Here the function returns 0 as the both strings are not equal. And the get type method will return the type of o as system.int32.
Joseph stalin said:
8 years ago
Anyone can explain how this logic works?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers