C# interview questions with answers
What are the different method parameter modifiers in C#?
out
ref
params
What are the different Iteration Constructs in C#?
for loop
foreach/in loop
while loop
do/while loop
What is the use of ?? operator in C#?
This operator allows you to assign a value to a nullable type if the retrieved value is in fact null.
What is the CIL representation of implicit and explicit keywords in C#?
The CIL representation is op_Implicit and op_Explicit respectively.
Which operators in C# provides automatic detection of arithmetic overflow and underflow conditions?
'checked' and 'unchecked' keywords provide automatic detection of arithmetic overflow and underflow conditions.
What is the use of stackalloc keyword in C#?
In an unsafe context it is used to allocate C# array directly on the stack.
Which keyword in C# is used to temporarily fix a variable so that its address may be found?
fixed keyword
What are the different C# preprocessor directives?
#region , #endregion :- Used to mark sections of code that can be collapsed.
#define , #undef :-Used to define and undefine conditional compilation symbols.
#if , #elif , #else , #endif :- These are used to conditionally skip sections of source code.
What is the use of GetInvocationList() in C# delegates?
GetInvocationList() returns an array of System.Delegate types, each representing a particular method that may be invoked.
C# delegate keyword is derived form which namespace?
C# delegate keyword is derived form System.MulticastDelegate.
What will be the length of string type variable which is just declared but not assigned any value?
As variable is not initialized and it is of reference type. So it's length will be null and it will throw a run time exception of "System.NullReferenceException" type, if used.
C# interview questions with answers
How can you check a nullable variable is assigned?
using hasvalue method
what is the syntax of a nullable variable?
Nullable myval=null;
I would like to check a variable as assigned or not. How can we do that?
Declare the variable as Nullable
What are the different compiler generated methods when a .NET delegate is compiled?
Compilation of a .NET delegate results in a sealed class with three compiler generated methods whose parameters and return values are dependent on the delegate declaration. The methods are,
Invoke()
BeginInvoke() and
EndInvoke().
When TimerCallback delegate is used?
Many application have the need to call a specific method during regular intervals. For such situations we can use the System.Threading.Timer type in conjunction with a related delegate named TimerCallback.
Which enumeration defines different PenCap in C#?
LineCap enumeration which defines different pen cap styles as follows,
public enum LineCap
{
Flat, Square, Round, Triangle, NoAncher, SquareAnchor,
RoundAnchor, DiamondAnchor, ArrowAnchor, AnchorMask, Custom
}
What is the use of param keyword in C#?
In C# param parameter allows us to create a method that may be sent to a set of identically typed arguments as a single logical parameter.
Worst-Case Interview Scenarios
Here are some suggestions on how to handle unforeseen interview mishaps.
You Forgot Your Résumé Materials.
You grabbed your briefcase, but left your portfolio stuffed with your beautifully printed résumés, letters of recommendation and work examples sitting on your kitchen table.
Solution: "This can be easily handled if you planned ahead properly," Guarneri suggests. "Don't rely on just a paper résumé. Have your résumé available online somewhere, such as a blog, personal Web site or in your e-mail. Then it can be instantly retrieved from the interviewer's office."
You Have a Wardrobe Malfunction.
Somewhere between your house and the interviewer's office your smartly pressed suit ends up looking stupid. This happened to one of Guarneri's clients who was splashed by a passing cab right outside the building of the company with which he was going to interview.
Solution: Guarneri recommends continuing to your interview and briefly explaining what happened. Almost everyone has had a wardrobe malfunction occur at an inopportune time -- your interviewer will likely be empathetic to your mud speckled trousers.
You're Late.
Whether you overslept or your train stalled on the tracks, either way, you know you're going to be late for your interview.
Solution: "If you can see you're going to be late, immediately call ahead and let them know," Guarneri advises. That way you won't keep your interviewer waiting and you give them the chance to call the shots -- squeeze you in for a later appointment or reschedule for another day.
The Interviewer is Distracted.
Another of Guarneri's clients entered an interview only to find the interviewer sitting with his head in his hands and didn't even look up when her client entered the room and sat down.
Solution: If they're not listening when you're talking, are they bored? Are they stressed with other projects?
"Pick up on the emotional cues the interviewer is delivering," Guarneri says. "Then recognize the situation and get their attention." In this case, her client said, "If this is a really bad time, I can come back."
You Forget the Name of the Person You're Interviewing With.
You're nervous during an interview and it's common for your mind to go blank.
Solution: If you didn't write it down on, don't see a nameplate on the desk, or can't read it off of certificates adorning the walls, don't fake it, Guarneri warns. Find an opportune time to ask the interviewer for his or her business card, by saying something like, "Before I forget, could have one of your business cards?"
Interview questions for asp.net Web application developers
- Name a few differences between .NET application and a Java application?
- Specify the best ways to store variables so that we can access them in various pages of ASP.NET application?
- What are the XML files that are important in developing an ASP.NET application?
- What is XSLT and what is its use?
- How do you separate business logic while creating an ASP.NET application?
- If there is a calendar control to be included in each page of your application, and we do not intend to use the Microsoft-provided calendar control, how do you develop it? Do you copy and paste the code into each and very page of your application?
- How do you debug an ASP.NET application?
- How do you deploy an ASP.NET application?
- What is the maximum length of a varchar field in SQL Server?
- How do you define an integer in SQL Server?
ASP.NET Page Life Cycle Overview
| Stage | Description |
| Page request | The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page. |
| Start | In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets theIsPostBack property. Additionally, during the start step, the page's UICulture property is set. |
| Page initialization | During page initialization, controls on the page are available and each control's UniqueIDproperty is set. Any themes are also applied to the page. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state. |
| Load | During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state. |
| Validation | During validation, the Validate method of all validator controls is called, which sets the IsValidproperty of individual validator controls and of the page. |
| Postback event handling | If the request is a postback, any event handlers are called. |
| Rendering | Before rendering, view state is saved for the page and all controls. During the rendering phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page's Response property. |
| Unload | Unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed. |
What are design patterns
Design patterns are documented tried and tested solutions for recurring problems in a given context. So basically you have a problem context and the proposed solution for the same. Design patterns existed in some or other form right from the inception stage of software development. Let’s say if you want to implement a sorting algorithm the first thing comes to mind is bubble sort. So the problem is sorting and solution is bubble sort. Same holds true for design patterns.
There are three basic classifications of patterns Creational, Structural, and Behavioral patterns.
Creational Patterns
• Abstract Factory:- Creates an instance of several families of classes
• Builder: - Separates object construction from its representation
• Factory Method:- Creates an instance of several derived classes
• Prototype:- A fully initialized instance to be copied or cloned
• Singleton:- A class in which only a single instance can exist
Note: - The best way to remember Creational pattern is by ABFPS (Abraham Became First President of States).
Structural Patterns
• Adapter:-Match interfaces of different classes.
• Bridge:-Separates an object’s abstraction from its implementation.
• Composite:-A tree structure of simple and composite objects.
• Decorator:-Add responsibilities to objects dynamically.
• Façade:-A single class that represents an entire subsystem.
• Flyweight:-A fine-grained instance used for efficient sharing.
• Proxy:-An object representing another object.
Note : To remember structural pattern best is (ABCDFFP)
Behavioral Patterns
• Mediator
efines simplified communication between classes.
• Memento:-Capture and restore an object's internal state.
• Interpreter:- A way to include language elements in a program.
• Iterator:-Sequentially access the elements of a collection.
• Chain of Resp: - A way of passing a request between a chain of objects.
• Command:-Encapsulate a command request as an object.
• State:-Alter an object's behavior when its state changes.
• Strategy:-Encapsulates an algorithm inside a class.
• Observer: - A way of notifying change to a number of classes.
• Template Method
efer the exact steps of an algorithm to a subclass.
• Visitor
efines a new operation to a class without change.
What will do if the employer ask for credit report?
I have answered many help wanted ads and have gotten very little response. Some of the responses are questions regarding my credit score. Is this something new? I did talk to a friend of mine and she told me her previous employer asked before continuing the application/interview process. I don't feel that that has any bearing on my qualifications, experience and education. Is it legal for employers to ask this information of people applying for work?
Alas, it's entirely legal for a prospective employer to request your credit report. But they can't do that without your explicit permission.
If you refuse to give the hiring manager authority to pull your report because there's stuff on it you don't want them to see, or you just think it's an invasion of privacy, you have every right to do that.
Unfortunately, the employer also has every right not to give you a job.
If you do agree to let them see the report, and they base their decision not to hire you on something in it, you have the right under the Fair Credit Reporting Act to see it, says EFL's Meschke. This will give you an opportunity to try to explain or rectify any issues or errors that may be on there.
The best thing to do is to get a copy of your credit report right now and make sure there's nothing on it that could derail your chances of landing a gig.
Under the Act, the credit reporting firms – TransUnion, Equifax and Experian – are required to give you a copy of your report for free once a year.
Also, if you do have stuff on there that may make an employer nervous, tell them upfront so there are no surprises when they see it, says Tim Mohr, a certified fraud examiner and partner with BDO Consulting.