C# Interview Questions and Answers (958) - Page 36

What will be the output of below code? int character_count = "Dot Net-Funda".Length;

Output will be 13.Because Length also count spaces,hyphen or any special characters from within string.So it will count all the characters.Here,the output will be 13.
What is the return type of IsNullOrEmpty string method?

IsNullOrEmpty string method returns Boolean value as True or False. If any string contains any

value then IsNullOrEmpty method returns True otherwise returns False.

For Example:-
string value = string.Empty;

if (string.IsNullOrEmpty(value))
{
return true;
}
else
{
return false;
}

Alternative way of checking string whether it contains values or not?

Use string Length static property to check where string is empty or not.

For Example:-
string value = "Vishal";

int length = value.Length;


Note:-If the variable length value is greater than 0 then string has a value assigned to it.
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 }

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'

In C# programming, the class in which we cannot use any new keywords for creating variables is?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following is a contextual keyword of C#?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following is an Identifier of C#?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, the Keyword which exposes its Variable to any other classes is known as?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, the type declared in another type is called?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, the variables which doesn't operate on Instance of a class are known as?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, the variables which doesn't include any static modifiers and operates on Instance of a class are known as?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, the variable which is declared inside a class but not in a method is called as?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, which type of variables are declared within the method of a class and also only accessible to that class?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, which of the following keyword is a 32-bit Integer?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, which of the following keyword is a 16-bit Integers?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, which of the following keyword is a 64-bit Integer?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, which of the following keyword is a 8-bit Integer?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, which of the following keyword is the unsigned 8-bit Integer?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, which of the following keyword is a 32-bit unsigned Integer?

NOTE: This is objective type question, Please click question title for correct answer.
In C#, which of the following keyword is a 64-bit unsigned Integer?

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories