Visual Studio Interview Questions and Answers (81) - Page 2

How to find the server last error?

We have a Server static method called GetLastError() through which we can find the Last error which gets occur.
For Example:-
Exception last_err = Server.GetLastError();

if (last_err != null)
Response.Write(last_err.Message);

How to Find No of Days in Month?

Suppose,we want to know how many days in December Month,then we have Datetime static method as DaysInMonth,which takes 2 numeric parameters as YEAR and MONTH.
DaysInMonth method returns total number of days.
For Example:-
int dec_month_days = DateTime.DaysInMonth(2014,12);

Ouuput:- 31 because December has 31 days.
int apr_month_days = DateTime.DaysInMonth(2014, 04); 

Output:- 30 because april has 30 days.
Which attribute is used for making method as obsolete?

NOTE: This is objective type question, Please click question title for correct answer.
Which keyword is used to exit from for loop in C#?

NOTE: This is objective type question, Please click question title for correct answer.
Which keyword is used to exit from for loop in VB.NET?

NOTE: This is objective type question, Please click question title for correct answer.
How to check if the Date is the first of every month?

We have Datetime'Day in-built property and is a numeric value,we have to check like below:-
DateTime dt = DateTime.Now;


if (dt.Day == 1)
{
Response.Write("First Date");
}
else
{
Response.Write("Not a First Date");
}

How to add a first date in given Month?

Just write below code:-
DateTime dt;

dt = new DateTime(dt.Year, dt.Month, 1);
Response.Write(dt.ToString());

Output would be 1st december.
Which way is used to check whether Textbox or any string value is empty or not?

NOTE: This is objective type question, Please click question title for correct answer.
What are the ways to Exit a method without Exiting a program.

There are 2 ways:-
1). Use the return keyword inside any condition and,
2). Throw an exception.
Which Process'method is used to Stop any processs which are being run in background?

NOTE: This is objective type question, Please click question title for correct answer.
CultureInfo class is placed inside which Namespace?

NOTE: This is objective type question, Please click question title for correct answer.
Which statement is/are true about Enum?

NOTE: This is objective type question, Please click question title for correct answer.
When do Constructors call?

NOTE: This is objective type question, Please click question title for correct answer.
Which statement is/are correct about Constant?

NOTE: This is objective type question, Please click question title for correct answer.
Which statement is/are correct about ReadOnly?

NOTE: This is objective type question, Please click question title for correct answer.
Which statement is/are correct about Static keyword?

NOTE: This is objective type question, Please click question title for correct answer.
Which are the Value Type Variables?

NOTE: This is objective type question, Please click question title for correct answer.
How to check the screen resolution in Dot Net?

We can use the System.Windows.Forms.Screen.PrimaryScreen.Bounds property to check screen resolution in Dot Net.
How to identify the working area of a screen without using the system-tray area?

The Screen.GetWorkingArea(control) will provide us the working area of a screen without the use of system tray area.
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