- World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.

Get it now !!
Send your Resume to 6000 Companies
C# Interview Questions & Answers - Learning Mode

C# Interview Questions & Answers - Learning Mode

C# (pronounced "C-sharp") is an object-oriented programming language from Microsoft that aims to combine the computing power of C++ with the programming ease of Visual Basic. C# is based on C++ and contains features similar to those of Java. C# is designed to work with Microsoft's .Net platform. It was developed by Microsoft within its .NET initiative and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270:2006). C# is one of the programming languages designed for the Common Language Infrastructure. C# is a general-purpose, object-oriented programming language.

Try C# Interview Questions & Answers - Exam Mode

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Next

Sort By : Latest First | Oldest First | By Rating

C# Interview Questions & Answers - Learning Mode
Try C# Interview Questions & Answers - Exam Mode
Question: what is the main difference between delegate and an event in c#?

Answer: They aren't the same. An event is an event. A "delegate" assigns a particular event handler to an object instance. Thus, when an object event happens, the proper procedure/method is called.

An example might help. I frequently code things so that a single method is called for all instances of a class. No matter which button is clicked, call my generic "button_click" method. That method will use the event arguments to determine which button was actually clicked.

In order to assig Source:
Question: What is the name of compiler?

Answer: csc Source:
Question: The C# keyword int maps to which .NET type

Answer: ans:

B) System.Int32
Question: Which class use to Read/Write data to memory

Answer: Ans: MemoryStream

It is a nonbuffered stream whose encapsulated data is directly accessible in memory(RAM not files on disk).
Question: What is the C# equivalent of System.Single

Answer: Ans: Float 32 bit

e.g. float i = 6.8F; // or 6.8f

By default, a real numeric literal on the right-hand side of the assignment operator is treated as double. Therefore, to initialize a float variable use the suffix f or F.

If you don't use the suffix in the previous declaration, you will get a compilation error because you are attempting to store a double value into a float variable.
Question: There can me more than 1 Main() functions in a C# program

Answer: It is possible to have multiple Main() methods in C# program. But, you have to explicitly identify which Main method is the entry point at the run-time. C++ and Java Programmers, take note that Main starts with capital 'M' and the return type is void.
Question: XML documents for a C# program can be generated using

Answer: (B) /doc will generate xml documents
Question: What is difference between deep copy & sallow copy?

Answer: Deep Copy-In Deep Copy it copies entire page or u can say all objects while in
Shallow Copy-It Copies the some of the object Source:
Question: What does the keyword virtual mean in the method definition?

Answer: If a base class have a virtual method it means that method must be override by the derived class using override keyword.
Question: How do I get deterministic finalization in C#?

Answer: In a garbage collected environment, it's impossible to get true determinism. However, a design pattern that we recommend is implementing IDisposable on any class that contains a critical resource. Whenever this class is consumed, it may be placed in a using statement, as shown in the following example:
using(FileStream myFile = File.Open(@"c:temptest.txt",
int fileOffset = 0;
while(fileOffset < myFile.Length)
Console.Write((char)myFile.ReadByte()); Source:
Question: If I return out of a try/finally in C#, does the code in the finally-clause run?

Answer: Yes. The code in the finally always runs. If you return out of the try block, or even if you do a "goto" out of the try, the finally block always runs, as shown in the following
example: using System;
class main
public static void Main()
Console.WriteLine("In Try block");
Console.WriteLine("In Finally block");
Both "In Try block" and "In Finally block" will be displayed. Whether the return is in the try block Source:
Question: How do destructors and garbage collection work in C#?

Answer: C# has finalizers (similar to destructors except that the runtime doesn't guarantee they'll be called), and they are specified as follows:
class C
// your code
public static void Main() {}
Currently, they override object.Finalize(), which is called during the GC process. Source:
Question: Is XML case-sensitive?

Answer: Yes, so and are different elements. Source:
Question: Explain ACID rule of thumb for transactions.

Answer: Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no ?in-between? case where something has been updated and something hasnot), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after). Source:
Question: Assemblies are of the following types:

Answer: There is shared assemblies which is used for diffrenent language interpotability. Source:
Question: What connections does Microsoft SQL Server support?

Answer: Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords). Source:
Question: To Configure .Net for JIT activation what do you do

Answer: Actually JIT activation is required for COM+ components which can be done by setting JustInTimeActivation attribute to true (choice A). For .net applications / components JIT comes in by default.

Question: What optimizations does the C# compiler perform when you use the /optimize+ compiler option?

Answer: The following is a response from a developer on the C# compiler team:
We get rid of unused locals (i.e., locals that are never read, even if assigned).
We get rid of unreachable code.
We get rid of try-catch w/ an empty try.
We get rid of try-finally w/ an empty try (convert to normal code...).
We get rid of try-finally w/ an empty finally (convert to normal code...).
We optimize branches over branches:
gotoif A, lab1
goto lab2:
turns into: gotoif !A, lab2
Question: Does C# support C type macros?

Answer: No. C# does not have macros. Keep in mind that what some of the predefined C macros (for example, __LINE__ and __FILE__) give you can also be found in .NET
classes like System.Diagnostics (for example, StackTrace and StackFrame), but they'll only work on debug builds. Source:
Question: Why do I get a syntax error when trying to declare a variable called checked?

Answer: The word checked is a keyword in C#. Source:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Next

India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.578125 Seconds