GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  ASP.NET 2.0
Go To First  |  Previous Question  |  Next Question 
 ASP.NET 2.0  |  Question 94 of 161    Print  
what is PreProcessor in .NET and type , where it use

  
Total Answers and Comments: 2 Last Update: March 27, 2006     Asked by: vishalsharma 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
March 23, 2006 05:55:26   #1  
Amar        

RE: what is PreProcessor in .NET and type , where it ...

The pre-processing directives provide the ability to conditionally skip sections of source files to report error and warning conditions and to delineate distinct regions of source code. The term pre-processing directives is used only for consistency with the C and C++ programming languages. In C# there is no separate pre-processing step; pre-processing directives are processed as part of the lexical analysis phase.
A preprocessor directive must be the only instruction on a line.
Preprocessing directives are lines in your program that start with `#'. Whitespace is allowed before and after the `#'. The `#' is followed by an identifier that is the directive name. For example `#define' is the directive
Types are:
#if #else #elif #endif #define #undef #warning #error #line #region #endregion

They are used for:
Conditional compilation
Line control
Error and Warning reporting

For example u can refere the MS site ...
http://msdn.microsoft.com/library/default.asp?url /library/en-us/csspec/html/vclrfcsharpspec_2_5_4.asp


 
Is this answer useful? Yes | No
March 27, 2006 14:39:46   #2  
rashid Member Since: March 2006   Contribution: 7    

RE: what is PreProcessor in .NET and type , where it ...

Attaching metadata to code using attributes is a great feature in .NET. We can use this feature to write code that is conditionally compiled and invoked during program execution. Earlier this was done in C/C++ using #ifdef statements. While this method can still be used in C# it leads to unclean code since the code gets sprinkled with preprocessor directives. The Java way of doing things is slightly better than C/C++. In Java debugging code is put within an if...else block as shown below.

public static boolean debug true;

if(debug)
{
MyDebugMethod(); // debugging action here...
}
The Java compiler is usually smart enough not to compile the call to the debugging method and not include it in the byte code when the debug variable is set to false. However all that has been accomplished is the replacement of a preprocessor directive of C/C++ with an if statement. Not a big change.

The System.Diagonostics.ConditionalAttribute attribute provides a much cleaner way of writing debugging code. Once methods that are exclusively used for debugging have been defined they are marked with the conditional attribute as shown below.

[Conditional( DEBUG )]
public void MyDebugMethod ()
{
// debugging code here...
}
When the debug method needs to be called it can be called just like any other method. The call is compiled by the C# compiler only if the compiler directive DEBUG has been defined. This entirely localizes the debugging nature of the method instead of the code globally being aware of it. Thus the code that uses this debugging method needs to do no special handling (like preprocessor directives or an if statement). Usually in Visual Studio .NET DEBUG and TRACE are both defined when the debug build configuration is chosen. If it is necessary to define these explicitly it can always be done by including the following statement at the top of any file.

#define DEBUG


 
Is this answer useful? Yes | No

 Related Questions

Latest Answer : There is the ability to use both server side and client side code with in the code behind. Generally though the code behind is server side code. This code acts on Events that are fired that are not handled by the client side script.(JavaScript,vbscript, ...

Latest Answer : #if #else #elif #endif #define #undef #warning #error #line #region #endregion Main use of directives ...
Read Answers (1) | Asked by : mdchaus

Latest Answer : Attaching metadata to code using attributes is a great feature in .NET. We can use this feature to write code that is conditionally compiled and invoked during program execution. Earlier, this was done in C/C++ using #ifdef statements. While this method ...

You have created an .aspx file that is viewed through a browser. In this scenario, the server sees the page as a running instance of what class type?
Read Answers (1) | Asked by : nits123

Question: Can you define basic element of WebServices and explain any one from them?Answer: These are as follows SOAP, WSDL and UDDI. And I am explaining about the SOAP(Simple Object Access Protocol) it 
View Question | Asked by : umesh_20012


 Sponsored Links

 
Related Articles

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

HR Interview - HR Interview Mistakes You Will Want To Avoid

HR Interview Mistakes You Will Want To Avoid The job interview can be a stressful process This is especially true for those who are going after a competitive position Your nonverbal communication combined with the answers you give during the interview will determine if you are hired mosgoogle While
 

HR Interview - Behavioral HR Interviews

Behavioral HR Interviews As the name implies a behavioral interview is an interview that is held by a human resources department to determine if an applicant has the behaviors that are appropriate for a job The company must know how an applicant will behave in a certain situations mosgoogle The logi
 

HR Interview - How To Prepare For Your HR Interview

How To Prepare For Your HR Interview Before you begin thinking about how you are going to dress for the interview it is important to do your research first You should learn everything you can about the company you wish to work for When you have detailed information about your employer you will conve
 

HR Interview - Telephone Interview Etiquette

Telephone Interview Etiquette When you conduct a telephone interview for a job it is important to show the proper etiquette Not only is it important it is critical is you wish to be hired by the company There are a number of things you will want to do and other things should never be done mosgoogle
 

HR Interview - How To Succeed At HR Interviews

How To Succeed At HR Interviews There are a number of things you will need to do in order to make sure you pass the interview process Your appearance is something that you will want to pay close attention to Even if you feel that your appearance shouldn t be a factor in whether or not you re highere
 

HR Interview - Do's and Dont's in a HR Interview

Do s and Dont s in a HR Interview There are a number of things that you will want to avoid during the HR interview process While some of these things are directed at the interviewer the other things are directed at the applicant If interviewers fail to follow the proper procedures throughout the int
 

HR Interview - HR Interview Tips

HR Interview Tips It has become more challenging for companies to find the right employees because of the market When you hold an interview for a potential employee there are a number of things you will want to keep in mind mosgoogle The goal of a company should be to hire an employee who can perfor
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape