What will happen if we compile below C# code? Whether it will compile or not.If compile then what will be the output?

1).
if (string.IsNullOrEmpty(false))
{
//code
}

2).
if (string.IsNullOrEmpty(1))
{
//code
}

 Posted by vishalneeraj-24503 on 7/1/2014 | Category: C# Interview questions | Views: 426 | Points: 40
Answer:

It will not give us any output because it will throw compile-time error as:-

The best overloaded method match for 'string.IsNullOrEmpty(string)' has some invalid arguments
Argument 1: cannot convert from 'bool' to 'string'
Argument 2: cannot convert from 'int' to 'string'


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response