Sei sulla pagina 1di 52

Public Members

Why do we use properties rather than public members?


Latest Answer: Because we can restrict the access from exterior to member variables of a class, by
providing for example only a getter for that field, in this way providing encapsulation, one of the core
principle of OOP. ...

AutoPostBack Property

There is Cancel button and OK button on page. When we click Cancel button it skips all validation controls
and goes to next page.(a)Page AutoPostback of Cancel is True.(b)Page AutoPostback of Cancel is
Latest Answer: Page AutoPostback of Cancel is True and also CausesValdation of cancel should be false ...

Namespaces

When do you apply Namespace Alias Qualifiers and Extern Namespaces Alias?
Latest Answer: It is supposed to be used when a member in program might be hidden by another entity of
the same name. ...

Explicit Implimentation

What do you mean by Explicit Interface Implimentation? What's Interface Mapping?


Latest Answer: When class implement interface, user mandatory needs to specify interface method body.
Such implementation is called as Exlicitimplementation. All the signature of interface API must be
compatible with interface API. Dervice class can also define theirown ...

C# Serializable Keyword

What is the use of serializable keyword in C#?


Latest Answer: Serializable is a concept of converting your user define type i.e. class into bytes. Serializing
object into bytes help for ease in transporting data within network or machines. .Net also provides support to
desializingWe can do Serializing in following ...

Postbackurl and Navigateurl

What is difference between "Session" and "Session" Objects? What is the use of "postbackurl" and
"navigateurl" and the differences between those two things?
Latest Answer: PostBackUrl is a property of the control which are in the "Button Family" and NavigateUrl is
property of the control in the "Link Family". ...

Object Oriented and Object Based Language

Explain What are Object Oriented Language and Object Based Language
Latest Answer: Any langauge based on encapsulation concpet and operations with the objects are called as
Object Based language. Exmaple : VB is a Object based and not an Object orientedAny langauge based on
encapsulation concept and operations with the objects and also ...
How to Do File Exception Handaling in C#
Latest Answer: Exception handling is an in built mechanism in .NET framework to detect and handle run
time errors. The .NET framework contains lots of standard exceptions. The exceptions are anomalies that
occur during the execution of a program. They can be because ...

What is page life cycle in c#.net


Latest Answer: Process Request Method does following things:Intialize the memory Load the view state
Page execution and post back events Rendering HTML content Releasing the memory Process Request
Method executes set of events for page class .These are called as Page ...

C# pointers

can we use pointer in c# ?if we can then how it can implement ?and if no then why we can not use pointer in
c#?
Latest Answer: we can use pointers in C# within the scope of unsafe code e.g.:unsafe{//all pointer related
code here}but doing so, makes ur code un managed.Also, if you want to have pointers to class level
variables, you must use fixed keyword. ...
Variable Declaration and Assignment
What is difference between these two statement? if variable is declared and assign value in following two
waysString sValue = (String)GridView1.DataKeys[GridView1.SelectedIndex].Value;String sValue =
GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
Latest Answer: .tostring method doesot handle null value where as other does..vijay ...

What is the default access specifier for a Top Level Class,which are not nested into another classes

What is the default access specifier for a Top Level Class,which are not nested into another classes

C# Program to test efficient coding

You have several instances of the following class (User). Provide a class with three methods:"AddUser"
accepts a User instance as a parameter and add it to a collection."GetUser" accepts
Latest Answer: Here's an easy way to take care of the sorting part by using the new Linq feature in .NET
3.5Assuming you have an ArrayList with all the user objects.ArrayList array = new ArrayList();Add all the
user objects...........//Arraylist isn't supported ...

C# Calender Days

how to find out how many calender days are there between two dates in c#.net?
Latest Answer: public void DateDiff(){ DateTime startDate = DateTime.Parse("11/12/2008"); DateTime
endDate = DateTime.Parse("11/12/2009"); if (endDate > startDate) ...

What the difference between Process and thread?

Latest Answer: A process is an entity that: 1) Receives independant resource allocations ( CPU, memory,
etc)2) Has its own address space ( which means that it can't access variables or data structures belonging
to a different process) 3) Maintains state ...

MFC GUI without flickering

User is continuously entering some in GUI and it is doing some background processing and updating in GUI.
How to do it without flickering the GUI using MFC?Thanks,Raja Gregory
Latest Answer: this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.UserPaint, true); ...

Classes Interface

Explain how many classes can an interface inherit?


Latest Answer: Interface cannot inherit classes.Interfaces are used to define the methods and properties
and the implementation is provided in the class that inherites interface ...

Design Patterns

What kind of design patterns can be used for C# development projects?


Latest Answer: A design pattern can solve many problems by providing a framework for building an
application. Existing design patterns make good templates for your objects, allowing you to build software
faster. There are several popular design patterns used ...

Delegates and Generics in c#

What is the advantage of using delegates and Generics in c# .


Latest Answer: Adding on sutanu_halder answer: 1. Delegate executes asynchronousely, while Generice
execute synchronousely. 2. Delegate is not type safe. We can define anonymous method which can execute
without creating delegate object in memory. Generic is type-safe. ...

Garbage Collector Generations Algorithm

Explain the Generations Algorithm used in the context of Garbage Collector


Latest Answer: Garbage collection in .Net is an automated process. All objects are swept by the GC to
check if they are still alive and are assigned a generation each sweep. The lower the generation the more
frequently the objects are checked for example a gen 1 may ...

'this' in C#
Explain about 'this' and where and when it should be used?
Latest Answer: i. this keyword refer to current instance. ii.this keyword help to provide intellisense support
during debugging. ...

Uses of delegates

What is a delegate in C# and when are they commonly used in Windows Forms programming?

Answer: Delegeates are reference to methods Delegates are most commonly used in event handling.

Threading

Write a very simple multi threaded program in C#. 1. The program should create two threads that each add
data to the same list at the same time. Then after they are both done, print out the entire list.
Latest Answer: See code below. In practice, the Thread.Sleep() is required - otherwise each thread will
complete its work in a single time-slice before the other gets a chance to start. An improvement would be to
create a "work item" class for the that would ...

Delegate

The following code illustrates a situation where a boss wants to keep track of the work progress of its
subordinates: using System;namespace BigCompany { public class Boss { public void
WorkerPercentageDone(int
Answer: public class Boss { public void WorkerPercentageDone(int percentage)
{ ...

Class Design
. Below is a set of birds and movements they can perform. Birds:Penguin:• hopping: moves 2 ft• flying: can't
flyHawk:• hopping: can't hop• flying: moves 100 ft; won't
Answer: using System;using System.Collections.Generic;namespace PCD{ public class World {
public static int temperature = 0; // celcius public ...

Data Structures

Assume you have large set of data, say more than 100,000 elements. Each data element has a unique
string associated with it. 1. What data structure has the optimal algorithmic access time to any element
Latest Answer: 1) Hashtable 2) 0(n-1)3) An arraylist which contains keys to a hashtable which contains the
data this covers all requirements. ...

Given colors, subtract the fade value and print

What is wrong with the following C# code? It should take the given colors and subtract the given fadeValue
and then print out the new faded values. Please copy and paste the code into your response and
Latest Answer: namespace PCD{ class MainClass { static void Main(string[] args) { int red=110; int
green=220; int blue=230; getFadedColor(ref red, ref green, ref blue, 10); getFadedColor(ref red, ref
green, ref blue, 20); Console.WriteLine("red: ...

What is the use of fixed statement in c#?

Latest Answer: Fixed is used while doing type casting Fixed ensures that no exception will be thrown even if
we are doing a wrong cast. ...

Which is not cls compliant built in value type?

intushortdecimalenum
Latest Answer: sbyte(System.SByte)ushort(System.UInt16)uint(System.UInt32)ulong(System.UInt64)are
non-cls compliant . ...

Which of the following is not a member of System.Object?

a)Instance equalsb)Static Equalsc)Instance referenceequalsd)Instance Gettype


Latest Answer: instance ReferenceEquals is not a memeber of Syste.Object.referenceEquals is static
method of System.Object,so its not instance type in nature.

How do you create a pure virtual function in c#?


Latest Answer: User abstract modifier on method. Class must also be marked as abstract.An abstract
method cannot have implementation. ...

Which keywords can do case insensitive string comparison in c#?

string.Equals("string number 1", "String NUMBER 1", StringComparison.CurrentCultureIgnoreCase) There is


also a similar override of String.Compare().
Latest Answer: all things in above sample are right bt one correction is there.there should
be OrdinalIgnoreCase instead of OriginalIgnoreCase.... ...

Which tags are used to include inline documentation in code?

Latest Answer: tag.usage :/// /// string usage array class./// public class teststring{public string s; }when we
create the object for teststring class or browse through the class explorer through intellisense we can see ...
Value of x

This is interview question,public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the
value of "x"?options:- A) 3 B) 2 C)4 D)
Latest Answer: Answer is 64 ...

Inheritance

what is the importance of inheritance in c# and why i used?


Latest Answer: Classes are inherit from another class. Basically we are using OOPS for reusability, so
inhertiance means deriving new class from base class, it occupies less memory. ...

C# sealed variables

I have taken a windows application and a button control in it.I want to declare a variable as a sealed and use
that variable with in same class as we cannot use in other class. class test {
Latest Answer: Classes can only be sealed. Methods, Properties, and variables cannot be sealed. ...

Abstract classes and virtual methods

Abstract classes can be overridden by virtual methods (true, false)


Latest Answer: It is designed to act as derived class. the class , which contain more virtual function is called
an abstract class. and it cannot be create as an object, and it is similar to Interface ...

What is side by side execution?How is it related to assemblies?

Latest Answer: Side-by-side execution is the ability to install multiple versions of code so that an application
can choose which version of the common language runtime or of a component it uses. Subsequent
installations of other versions of the runtime, an application, ...

What is global pointer?

Latest Answer: Global Pointer Example Program The following walkthrough will illustrate a simple example
of global pointers. There are actually two seperate source code files involved, since, in this example, we are
going to be executing ...

The following code fails. Why? int a = 5; int b = 5; object oa = a; object ob = b; Debug.Assert(oa ==

The following code fails. Why? int a = 5; int b = 5; object oa = a; object ob = b; Debug.Assert(oa == ob, "oa
is not equal ob");
How do you create class diagram for .net code class?
Latest Answer: Just right click on the .cs file and select the option view class diagram.A diagram file .cd will
be generated.Further u can add method to the .cd file and extract interface etc from it.

Only a 'Static' method can be called using delegate - True / False? Give Reason

Latest Answer: false in c# ...

What are multiple delegates?Can 2 delegates in a class can refer to a same method?

Latest Answer: multiple delegates and multicast delegates both are diffrent terms with diffrent
aspects.delegate having one property that it could have multiple delegates in it.it means single delegates
contain multiple delegates definition whilein other case multicast ...
How to invoke the run command in client system

Explain the advantages and limitations of using Aliases in C#?

Latest Answer: Aliases can be useful in the case if you are using a lenthy namespace.You can create an
aliase for namespace and can acess its classes via alias.On the negative side it can cause some conflicts if
you declare any class with same name in that scope.But ...

What are public, private and static constructors and differences between them?

Latest Answer: Public constructors are used to instantiate and initialize the fields during object
instantiation.Private constructors are used to restrict the instatiation of object using 'new' operator. This type
of constructors are mainly used for creating singleton ...

Is it possible to have different access modifiers on the get/set methods of a property? Justify

Latest Answer: Yes you can do it in .net 2.0 onwardsstring name;public string Name{get { return name; }
protected set{name = value;}}You cannot specify access modifier for both getter and setter at same time.
The other will always take the default from property. ...

What is ref parameter?What is Out parameter?What's the difference between these two?

Latest Answer: Oops...The difference is that for a ref parameter, you have to assign a value before you call
the function, while for OUT parameter, you dont have to assign a value, the calling function assumes that
the called function would assign some value. ...

What is the difference between Cast and Convert int i1 = 5;double d1 = i1 + 0.99;int i2 = (int)d1;

What is the difference between Cast and Convert int i1 = 5;double d1 = i1 + 0.99;int i2 = (int)d1; //result is
5i2 = Convert.ToInt32(d1);//result is 6Why does cast and convert in above example have different results.

Which Variable type is best to choosen for accepting Null Values?

Latest Answer: In .NET 1.1 you can use the type "object" to store the values. You then have the choice
of setting the object reference to "null" or storing the value. The issue here is that the object could contain
any type of information...

How do you create Custom Dictionary? What is the use of it?


Latest Answer: goto>control panel->system->advanced->user variables.goto the Path title and edit it. Add
the path of C# compiler. then save and exit. it's same as SETPATH in JAVA. the you can create your dir
anywhere in your HDD and run program from DOS prompt. ...

What is late binding and early binding? What is the benefits and disadvantages of using them?

Latest Answer: Binding refers the object type definition. You are using Early Binding if the object type is
specified when declaring your object. Eg if you say Dim myObject as ADODB.Recordset that is early binding
(VB example). If on the other hand you declare ...

What is boxing? What is the benefits and disadvantages of it?

Latest Answer: Boxing is converting a value-type to reference type. An example is converting an integer
value to an object value.Ex: int intValue = 10; object obj = (object)intValue;This is used if you want to pass
variables of object types ...

Is it possible to override a sealed method with New keyword?


Latest Answer: The New keyword just hides the base's sealed method it does not really override the
method. ...

What is the difference between serialization and encoding?

Latest Answer: Searilization deals with converting objects into streams same as marshaling. mostly it relates
with objects, while transfering over network like that. when it comes to encoding it relates with security
aspects, data security, converts data into an encoded ...

How to use .pdb file

Latest Answer: .pdb files are used to debug.Take an example where assembly a1.exe is referenced a1.dll (
for which you dont have the code).In this instance anytime if you want debug the code which is in a1.dll, you
can request for the a1.pdb file (this will be generated ...

What is .net Attrubute

Latest Answer: .NET Attributes provide the means for a developer to add meta-data that describes, or
annotates, specific elements of code such as classes, methods, properties, etc. At compile time, the
resulting metadata is placed into the Portable Executable (PE)file, ...

What is the difference between encoding and serialization in .net?

Latest Answer: Serialization: ------------------Serialization in .NET allows the programmer to take an instance
of an object and convert it into a format that is easily transmittable over the network or even stored in a
database or file system. This object will actually ...

Internal class Piston{}internal class Engine{private Pistone[] myPistones = new Piston[4];

Internal class Piston{}internal class Engine{private Pistone[] myPistones = new Piston[4]; public bool
Ignition() { // some code..... return; }}public class Car{ private Engine myEngine = new Engine(); public void
Start() { // put in keys etc........... if(myEngine.ignition()) { //some code ....

Which an instance constract of a struct type, which one of the following key workds behaves exactly

Which an instance constract of a struct type, which one of the following key workds behaves exactly as an
output parameter of the struct type?1) value2) ref3) object4) this
What are Indexers?What is the use of it,and when to use Indexers?
Latest Answer: Indexers are one neat feature of C#. They allow us to access a particular class as it is an
array. They are similar to the properties in means that they encapsulate method calls into more convenient
representation of value access and value setting. Declaring ...

Why inheritance is not supported by structures??

Latest Answer: The Main facts for Inheritence to any thing that is it should worked as Base. And Structure
could not worked as Base due to it is Value type. So, Inheritence is not supported by Structure. ...

What is a read only object? e. g.static readonly object padlock = new object();

Latest Answer: A read only member is like a constant in that it represents an unchanging value. The
difference is that a readonly member can be initialized at runtime, in a constructor as well being able to be
initialized as they are declared. For examplepublic class ...

How can we say one exe is developed in .net Compatible languages or not?
Latest Answer: There are two easy methods1) No programming: Load the EXE/DLL with ILDASM.exe if it
is .Net programed than it will work otherwise it will throw error. 2) Programatically: Use reflection API to
LoadAssembly. It it is not a .Net program it will throw exception. ...

How can we say one.exe is compatible with .net or not?

Latest Answer: All dll's and exe's generated by .NET applciations are ASSEMBLIES. To test a .exe whether
its a .NET assembly or not , you need to use following code.try{AssemblyName assemblyName =
AssemblyName.GetAssemblyName(FullPATHofFile);Console.WriteLine("{0}

What is difference between dispose() & finalize() in c#?how database remotely connected?

Latest Answer: Dispose is called explicitly by the user whereas finalize is called by garbage collector when
ever it assumes to be appropriate.usually we use dispose method to free resources of our custom classes.
Dispose can be implemented by using IDISPOSABLE interface ...

In which scenerio we use interfaces,abstract and concrete class?Which one is better and
appropriate?Differentiate

In which scenerio we use interfaces,abstract and concrete class?Which one is better and appropriate?
Differentiate these three terms in depth.

What are Application blocks

Latest Answer: Application blocks are re-usable source code components that are common development
challenges.These components can be easily be integrated and customized to suite your requirements. ...

Who calls the main method ??

Latest Answer: CLR is the correct answer ...

We have a dataset with one thousand records. Now we bind it to a datagrid. Now the question is
suppose

We have a dataset with one thousand records. Now we bind it to a datagrid. Now the question is suppose
we have modified only three records in datagrid then how to update these three records in dataset. We have
a single button to update the records

If we have 2 interfaces, say Ix and Iy, and also we have one method in both interfaces with same
signature.
If we have 2 interfaces, say Ix and Iy, and also we have one method in both interfaces with same signature.
Now we have to inherit a class from both interfaces so how to access the method of interface Ix or that of Iy.

What are the drawbacks of a delegate

Latest Answer: When invoking multicast delegates, if any of the implementing methods throws an exception,
it will prohibit the pending methods from invocation. A way around this is to explicitly iterate the
delegates and invoke them inside a try-catch ...

How to handle exceptions without using try catch finally

Latest Answer: We Can handle exception without using Try/Catch Block in Global. asax file.It can be
handled in Application_error event. ...

System.UInt64 is equivalent to :
ulong
Latest Answer: System.Int32 ...

Output of int sqrt(volatile int *ptr){ return (*ptr**ptr);}

Latest Answer: square of value at memory whose address is defined by ptr. ...

How to upload a file in c# console application

Latest Answer: Use System.Net.WebClient Class use UploadFile method provided by the class. It accepts
the Uri or string as destination and another parameter as location of file to be uploaded. ...

What are the different types of access modifiers

Latest Answer: Hi All, The different types of access modifiers are 1. private 2. public

How can i hide the base class method in derived class?

Latest Answer: Yes - using System; public class Parent{ string parentString; public Parent() {
Console.WriteLine("Parent Constructor."); } ...

What is difference b/n c# and c#.net?

Latest Answer: Actually, both are same. The difference lies in your preference to call the same thing. Like
SQL Server, some call it as "es queue el server", while some call it as "sequel server" ...

If we can'nt make the object of abstract class what is the use of defining of data members and

If we can'nt make the object of abstract class what is the use of defining of data members and non abstract
functions in that abstract class?

Is there any way by which a class is made sealed as in C# that other class cannot inherit from it.
Please
Is there any way by which a class is made sealed as in C# that other class cannot inherit from it. Please
include code.

What is the difference between shadow and override

override id used for variables and methods but override only used for methods.
Latest Answer: The best way, in my opinion, to understand the true meaning of the effects of using the
"new" modifier in a virtual hierarchy is to think of it like this... The runtime wants to start at the top of the
virtual hierarchy and work towards the ...

You have an event handler called MyEvent and you want to link the click event of control, MyButton,

You have an event handler called MyEvent and you want to link the click event of control, MyButton, to use
MyEvent, what is the code that will like them together?

Where are custom exceptions derived from?

Latest Answer: System.ApplicationExeption ...

Which debugging window allows you to see the methods called in the order they were called?

Latest Answer: The call stack ...

Which debugging window allows you to see all the name and values of all the variables in scope?
Latest Answer: Auto, Local, Watch ...

What is wrapper class?is it available in c#?

Latest Answer: wrapper class are those class in which we can not define and call all predefined function .it is
possible in java not C#. ...

What is protected internal class in C#

Latest Answer: Hi, A class contain different access modifier. The Protected and Protected Internal are two
access modifier..Protected ; can only access with in the base class and also accessible from the derive
class.Protected Internal ; can only access with in base ...

Which keyword is used of specify a class that cannot inherit by other class

Latest Answer: By using "sealed" keyword we can restrict a class from inheritence. Please reply me if it is
wrong! ...

Can u create the instance for abstract classes

Latest Answer: We can create an instance of an abstract class.The below code is not working:sayHello is an
abstract classObject o=System.Activator.CreateInstance(typeof(sayhello)); ...
Can we use Friend Classes or functions in C# the way we use it in C++

How we can use inheritance and polymorphisms in c# programming?

Latest Answer: When you derive a class from a base class, the derived class will inherit all members of the
base class except constructors, though whether the derived class would be able to access those members
would depend upon the accessibility of those members in ...

How to find exceptions in database

Latest Answer: framework is endowed with provider specific exception class that u can use to handle
exception from database. for instance to handle exceptions from SQL Server u can use
System.Data.SqlClient.SqlException class. Similarly, for OLE DB data source ...

How can objects be late bound in .NET?

Latest Answer: Objects are generally late bound when using class factories with interfaces (or base
classes). An example of late binding can be seen below. The function that generates the concrete object (at
runtime) will decide which type of concrete object to instantiateIReader ...

How we can set the background color of a particular sheet in VSTO

Latest Answer: You need to use the color class to change the background colour -ex ::
this.BackGroundColor=Color. Red ();

How can I set formatting defaults to a chart's series, before populating data to the chart. For

How can I set formatting defaults to a chart's series, before populating data to the chart. For example for
each chart there must be a different color for each name series like that. Is there any method to store these
defaults to the excel template, other than pragmatically. Please explain based on VSTO 2005.

Where we can use DLL made in C#.Net

We can use the .net DLLs only in the applications supporting .NET.
Latest Answer: Hi Main purpose is to refer another class library ...
What Datatypes does the RangeValidator Control support?

Integer. String and Date


Latest Answer: int, date, string...

Constructor is the method which is implicitly created when ever a class is instantiated. Why?

Latest Answer: Only default constructor is called automatically and that is to only to zeroed down the data
types you have declared in your class,and that is for avoiding initialization error for your class... ...

Why multiple Inheritances is not possible in C#? (Please do not answer like this-It is possible
through

Why multiple Inheritance is not possible in C#?(Please do not answer like this-It is possible through
Interfaces.)
Why strings are immutable?
Latest Answer: In .net CLR maintain string pool for handling string operation.CLR not make any new string
object bt it uses string object refrnece from string pool.when we define new string object with same array of
character thn CLR assign same memory refrence ...

This is a Regular expression built for parsing string in vb.net and passed to Regex class.Dim r As
Regex

This is a Regular expression built for parsing string in vb.net and passed to Regex class.Dim r As Regex =
New Regex(",(?=([^""]*""[^""]*"")*(?![^""]*""))")What is C# equivalent for this regular expression.

How to convert ocx into DLL

Latest Answer: use the aximp.exe provided with the .NET framework. It stands for Microsoft .NET ActiveX
Control to Windows Forms Assembly Generator.Generates a Windows Forms Control that wraps ActiveX
controls defined in the given OcxName.Usage: AxImp OcxName ...

What is the main difference between pointer and delegate with examples?

Latest Answer: Delegate to function--- is same as---- pointer to object.Delegates are function pointers.They
are used when the function which needs to be called is not know at compile time.Pointers, on the other
hand, are used to point to variables or object references ...

What is object pooling

Latest Answer: Object Pooling is a COM+ service that enables you to reduse the overhead of creating each
object from scratch. When an object is activated, it is pulled from the pool.When the object is deactivated, it
is placed back into the pool to await the request. ...

How do i read the information from web.config file?

Latest Answer: we can also call configuration manager in vs 2005


system.configuration.configurationmanager() ...

What is the default Function arguments?

Latest Answer: C# does not support optional arguments.you can use function overloading to achieve the
same. ...

What is XML Schema?


Latest Answer: Document Type Declaration(DTD)determines the name of the root element and contains the
document type declarationsElementsElements are the main building blocks of both XML and HTML
documents.Examples ...

How can i check whether a dataset is empty or not in C#.net

Latest Answer: IsNothing is only used in VB or VB.NET. someone is really confused ...

Is it possible to inherit a class that has only private constructor?

Latest Answer: I have tried the above with including static method in the base class. But it giving me the
'inaccessible due to protection level' error. And one more thing some members told that "internal scope"
method. Can any body give me the idea....or ...

How do you choose 1 entry point when C# project has more Main( ) method?
A) Not PossibleB) Using /Main along with class name in csc.exeC) By just providing the class name to
csc.exe
Latest Answer: open the project properties, in the common properties/general set the start up object(it will
list all the classes having main function). ...

The compiler throws an error if XML comments is not well formed

A) TrueB) False
Latest Answer: If the XML is not well-formed, a warning is generated and the documentation file will contain
a comment saying that an error was encountered. For more information on well-formed XML, ...

Which of the following is not a C# reserved keyword

A) IsB) AsC) InD) Of


Latest Answer: a ...

By declaring a base class function as virtual we allow the function to be overridden in subclasses

A) TrueB) FalseExplanation: If a function is declared virtual it needs to be overridden in subclass

Which of the following can not be declared as virtual

A) Static functionsB) Member fieldsC) Instance functions


Latest Answer: (A) - "A static member ..... cannot be marked as override, virtual, or abstract(B) - "The
modifier 'virtual' is not valid for this item ...

Sealed class can be inherited

A) TrueB) FalseExplanation: Sealed class cannot be inherited


Latest Answer: False. The sealed class can not be inherited. This can be acheived by using the keyword
"sealed". what this keyword does, it tells the compiler that it is the last class in the class hierarchy. The best
example of sealed class is "String Class." Moreover, ...

Which of the following statements is not true for interfaces

A) Interface definitions does not have implementationB) Interfaces must be declared as publicC) Interfaces
can be instantiatedD) Interface does not have constructorsExplanation: Interfaces can only be
Latest Answer: Interface definition does not have implementation, they contain only signatures of methods,
delegates or events. Interface members are implicitly public, explicit modifiers are not allowed.Interface
cannot be instantiated directlyInterface cannot ...

It is not permitted to declare modifier on the members in an interface definition

A) TrueB) False
Latest Answer: Interface members are implicitly public, explicit modifiers are not allowed. ...

Interface members can not be declared as

A) VirtualB) StaticC) PrivateD) All of the above


Latest Answer: answer is all of the aboveinterface members are implicitly public, explicit modifiers are not
allowed. ...

Which method is implicitly called when an object is created

A) Main MethodB) Constructor MethodC) Destructor MethodExplanation: Constructor is the method which is
implicitly created when ever a class is instantiated
Latest Answer: Constructor is called when a class is instantiated. ...

Which of the following statement is invalid with regards to constructor


A) Constructors should have the same name as class nameB) Constructors have to be public so that class
can be instantiatedC) Constructors can not be overloadedExplanation: Constructors can be overloaded
Latest Answer: Two statements are INVALID: B -- since constructors can be protected / private. A class with
a protected constructor can be instantiated through a derived class. A class with a private constructor can be
instantiated through a friend class / friend function.C ...

Constructors can not be static

A) TrueB) FalseExplanation: There can be static constructors


Latest Answer: False.Constructors can be static only for static members of class ...

It is perfectly legitimate to throw exceptions from catch and finally blocks

A) TrueB) False
Latest Answer: There is no need to avoid throwing exceptions from finally block as a matter from any parts
of the code. The main idea of throwing exception is to inform caller of this block of the code about the
execption. Imagine a class library may have ...

It is not possible for a delegate to wrap more than 1 methos

A) TrueB) FalseExplanation: It is possible and such delegates are called as Multicast delegates
Latest Answer: FalseIn some cases you may want to call not just one, but two or more methods through a
single delegate. This is known as multicasting. You accomplish multicasting by encapsulating the various
methods in delegates, and then you combine the delegates using ...

In C# events are actually a special form of delegates

A) TrueB) False
Latest Answer: #2 is right and gave acurate definition of event and event handler but since we declare a
event using delegate so we usually say a event is a delegate but from the declaration we can see what is a
delegate is the eventhandler. ...
Which preprocessor directive are used to mark that contain block of code is to be treated as a single

Which preprocessor directive are used to mark that contain block of code is to be treated as a single block
A) # define & #undefB) # Region & #EndRegionC) #Line

How are the attributes specified in C#

A) Enclosed with in [ ]B) Enclosed with in ( )C) Enclosed with in { }


Latest Answer: Ans: A. They are enclosed with in []. ...

For performing repeated modification on string which class is preferred

A) StringB) StringBuilderC) Both

Latest Answer: Answer B is correct. StringBuilder class is preferred for performing repeated operations on
string since its value is mutable. String class represents a text value which is immutable. All operations on
string class which appear to be modifying its value ...

In order to use stringbuilder in our class we need to refer

A) System.TextB) System.IOC) System.StringBuilder


Latest Answer: System.Text name space should be used. ...

Which of the following is not a member of stringbuilder

A) Append ( )B) Insert( )C) Replace ( )D) Substring( )


Latest Answer: Answer: DSubString() is not a method of StringBuilder class.For the rest, here are the
details.....System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("Kals"); //string
value to be appendedsb.Insert(0, ...
Which method is actually called ultimately when Console.WriteLine( ) is invoked
A) Append( )B) AppendFormat( )C) Tostring( )
Latest Answer: I think String.Format() is called that ultimately calls StringBuilder.AppendFormat() and
StringBuilder.Append() .AppendFormat in turn calls ToString(). ...

What happens when you create an arraylist as ArrayList Arr=new ArrayList()

A) An arraylist of object Arr is created with the capacity of 16B) An arraylist of object Arr is created with the
capacity of 20C) An arraylist of object Arr is created with the capacity of 26Explanation:
Latest Answer: In .Net v1, default initial capacity of ArrayList is 16.In .Net v2, default initial capacity of
ArrayList lowered to 4.In .Net v3.5, default initial capacity of ArrayList lowered to 0.Now, when you add the
first element to a new arraylist it sets ...

What is the output of Vectors.RemoveAt(1)

A) Removes the object whose key is 1B) Removes the object whose value is 1C) Removes the object at
position 1

Latest Answer: Correct Answer: CRemoves the object at postion 1. Vectors.RemoveAt(int index); Default
index value is 0. If the default value is not changed for it, it removes the second element from the collection.

GetEnumerator( ) of Ienumerable interface returns

A) IenumeratorB) IcollectionC) Ienumerable


Latest Answer: The foreach loop automatically uses the IEnumerable interface, invoking
GetEnumerator( ).The GetEnumerator method is declared to return an IEnumerator of string:public
IEnumerator GetEnumerator( ) ...

How do you add objects to hashtable

A) With Add methodB) With insert MethodC) With = operator


Latest Answer: See the example here:Hashtable ht = new Hashtable(); ht.Add(0, "Kals");ht.Add(1, "Kal");
(or)ht[0] = "ABC"; ht[1] = "XYZ"; ...

If A.equals(B) is true then A.getHashcode & B.getHashCode must always return same hash code

A) TrueB) False
Latest Answer: Yes Ans (A) is right. If two objects compare as equal it must both return same hash code. ...

The assembly class is defined in

A) System.ReflectionB) SystemC) System.InteropServices


Latest Answer: System.Reflection.Assembly a = new System.Reflection.Assembly(); ...

What is the first step to do anything with assembly

A) Load corresponding assembly to running processB) Query the assemblyC) None


Latest Answer: Answer is (A) Load assembly to running process ...

How do you load assembly to running process

A) Assembly.Load( )B) Assembly.LoadFrom( )C) Both


Latest Answer: we can load to by usingAssembly obj=Assembly.load("path");orAssembly
obj=Assembly.LoadFrom("path"); ...

Assemblies cannot be loaded side by side

A) TrueB) FalseExplanation: Assemblies can be loaded side by side


Latest Answer: True.Assemblies can be loaded side by side. Different versions of same assemble can be
used inside a single process.Source: Professional C # 2005. Wrox edition ...

Application Isolation is assured using


A) ThreadsB) RemotingC) ApplicationDomain
Latest Answer: ans:C) ApplicationDomain ...

Where does the version dependencies recorded

A) Inside an assembly’s manifestB) Along with the project propertiesC) Both


Latest Answer: Answer: A) Inside an assembly’s manifest ...

How do you refer parent classes in C#

A) SuperB) ThisC) Base


Latest Answer: Super : Super is used to Refer the Base Class in JAVAThis : This is used to Refer the
Current or Child Class in C#Base : Base is used to Refer The Parent or Base Class ...

Which attribute you generally find on top of main method

A) [assembly]B) [ STA ]C) [ STAThread ]


Latest Answer: [STA] stands for Single Threaded Apartment.professional C#,3rd edition pg574 ...
How do you make a class not instantiable

A) Making class as AbstractB) Having a Private constructorC) Making the class sealedD) Both A & B
Latest Answer: private contructor ...

In a multilevel hierarchy how are the constructors are called

A) TopDownB) BottomUpC) None


Latest Answer: It will always be topdown: class a { public a() { Console.WriteLine("Class a");
Console.ReadLine(); } } class b:a { public b() { Console.WriteLine("Class b"); Console.ReadLine(); ...

Which utility is used to create resource file

A) regasmB) resgenC) regsvrExplanation: Resgen.exe is used to create resource files in C#.net


Latest Answer: ans:B) resgen ...

What is the extension of a resource file

A) .csB) .rsxC) .resx


Latest Answer: ans:C) .resx ...

A shared assembly must have a strong name to uniquely identify the assembly

A) TrueB) False
Latest Answer: Answer: A) TrueA shared assembly must have a strong name to uniquely identify the
assembly. The strong key is created by using the commandsn -k assemblyname.snk ...

Public policy applies to

A) Shared assembliesB) Private assembliesC) Both


Latest Answer: Public policies are applied on Shared Assemblies. ...
Stream object can not be initialized
A) TrueB) FalseExplanation: Stream is an abstract class ie it is the representation of bytes
Latest Answer: ans:A) True ...

Which of the following has stream as the base class

A) Buffered StreamB) MemoryStreamC) FileStream


Latest Answer: All the above choices are correct. ...

Which class use to Read/Write data to memory

A) FileStreamB) NetworkStreamC) MemoryStream


Latest Answer: Ans: MemoryStreamIt is a nonbuffered stream whose encapsulated data is directly
accessible in memory(RAM not files on disk). ...

To Configure .Net for JIT activation what do you do

A) Set JustinTimeActivation attribute to TrueB) Set JustinTimeActivation attribute to FalseC) None

Latest 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.

Which method is used by COM+ to ascertain whether class can be pooled

A) Pooled( )B) IsPooled( )C) CanbePooled( )


Latest Answer: (C) CanBePooled ...
How do you import Activex component in to .NET

A) With AXImp.exeB) With Pinvoke.exeC) With Tlbimp.exe


Latest Answer: An application called AXImp.exe shipped with .Net SDK is used.This application does
something similar as Tlbimp.exe does for non graphical COM components.It creates a wrapper component
that contains the type information that the .Net runtime can understand. ...

.Net Remoting doesn’t allow creating stateless & stateful Remote objects

A) TrueB) False
Latest Answer: ans:B) False ...

Windows services created by C# app run only

A) Windows 95B) Windows 98C) Windows NT & Above


Latest Answer: ans:C) Windows NT & Above ...

The C# keyword int maps to which .NET type

A) System.Int16B) System.Int32C) System.Int64


Latest Answer: ans:B) System.Int32 ...

What is an indexer in C#

A) Special syntax for overloading [ ] operator for a classB) One which speeds up the function callC) None of
the above
Latest Answer: Ans: Answer: A) Special syntax for overloading [ ] operator for a classB) One which speeds
up the function callC) None of the above

In the following cases which is not function overloading


A) Same parameter types but different return valuesB) Varying number of parametersC) Different
parameters types but different return valuesD) Different parameters type but same return values
Latest Answer: A is wrong...Rest of all the way to overload function ...

How to implement multiple inheritence in C#

A) Using InterfaceB) Using Abstract classC) Using DelegatesD) Using Events


Latest Answer: (a) by the help of interface ...

In C# a technique used to stream the data is known as

A) WadingB) SerializationC) CrunchingD) Marshalling


Latest Answer: ans:B) Serialization ...

Can static methods be overridable?

A) YesB) NoC) It depends on how we declare themExplanation: Static methods cannot be overridable
Latest Answer: No ...

What is the use of fixed statement

A) To stop the garbagecollector to move the objects in useB) To dispose the object at the end of the defined
scopeC) To tell the garbage collector to move the object is useD) To fix the size of an object.
Latest Answer: Ans: AThe fixed statement sets a pointer to a managed variable and "pins" that variable
during the execution of statement. Without fixed, pointers to managed variables would be of little use since
garbage collection could relocate the variables unpredictably. ...

What is the order of destructors called in a polymorphism hierarchy

A) Starts with derived class ends at base classB) Starts with base class ends at derived classC) The
destructor of base can not becalledD) RandomlyExplanation: Uses Bottomup approach while calling
Destructors
Latest Answer: I believe "Sahu" is intentionally posting wrong answers to questions, in order to mislead
others. Otherwise how could he be consistently getting the answers wrong almost always!! ...

How can you sort the elements of the array in descending order

A) Sort methodsB) Reverse methodsC) By calling Sort and then Reverse methodsD) Can’t sort in
descending
Latest Answer: First use the Sort() method, then use the Reverse() method. ...

Is it possible to Override Private Virtual methods

A) YesB) NoC) Either A or BD) None


Latest Answer: (B) No: First of all you cannot declare a method as 'private virtual'. ...

What does the volatile modifier do

A) The value of the object is written immediately on assignmentB) The value is lost after the system reads
it.C) The system stored the value until the end of all current threadsD) The system always reads
Latest Answer: Ans - A and DWhenever a volatile is requested, the system returns the current value at the
time of the request.All assignments are written to the object immediately. Common usage of the volatile
modifier is when a particular field is accessed by ...

What is the C# equivalent of System.Single

A) Float (16-bit)B) Float (32-bit)C) Float(64-bit)


Latest Answer: Ans : BSingle is a 32-bit single precision floating-point type that represents values ranging
from approximately 1.5E-45 to 3.4E+38 and from approximately -1.5E-45 to -3.4E+38 with a precision of 7
decimal digits ...

A single line comments are implemented by


A) ‘B) //C) /*D) !—
Latest Answer: Ans:B) // ...

Code running under the control of CLR is often referred as

A) Source CodeB) Managed CodeC) Unmanaged CodeExplanation: Source code is compiled to MSIL,
which is generally known as managed code
Latest Answer: Managed Code ...

Platform specific code is obtained when

A) source code is compiled to get MSILB) when MSIL is compiled by CLRC) Both of the aboveExplanation:
When CLR compiles the managed it generates the native code which is compatible to platform.
Latest Answer: (B) Is correct. MSIL is platform independent code whereas JIT compiled code is platform
dependent code. ...

Intermediate Language also facilitates language interoperability

A) TrueB) FalseExplanation: AS the managed code is bound to CTS & CLS it is language interoperable
Latest Answer: Ans:A) True ...

Which are the important features of IL

A) Use of attributesB) Strong data typingC) Object orientation & use of interfaceD) All of the above
Latest Answer: Ans:D) All of the above ...

.NET interfaces are not derived from IUnknown & they do not have associated GUID’s

A) TrueB) FalseExplanation: Only COM interfaces are derived from Iunknown and they do have GUIDs
Latest Answer: Ans:A) True ...

Code written in C# can not used in which of the languages

A) J#B) Managed C++C) Vb.NetD) JavaExplanation: Java is not targeted to run under CLR
Latest Answer: ans:D) Java ...

It is not possible to debug the classes written in other .Net languages in a C# project.

A) TrueB) FalseExplanation: It is possible to debug the code as all are adhering to CTS & CLS
Latest Answer: May i assume that results by sisira is wrong always? ...

Which of the following is not a subclass of Value Type class

A) EnumerationsB) User defined value typesC) Boxed value typesExplanation: Boxed value types are of
reference types
Latest Answer: Boxed types are those types that have been converted from being a value type to a
reference type. So once they are boxed, they cease to be a value type and become a reference type
instead.Answer is C. ...

Which of the following is not a subclass of reference type

A) EnumerationsB) DelegatesC) ArraysExplanation: Enumerations are of Value Type


Latest Answer: ans: A) Enumerations

Which is .NET s answer to Memory Management


A) ReflectionB) Common Type SystemC) GarbageCollection
Latest Answer: Ans:C) GarbageCollection ...

.NET run time relies on the object reference counts to manage memory

A) TrueB) FalseExplanation: .Net run time relies on Garbage Collection to manage memory
Latest Answer: One of the primary design goals of .NET is to overcome problems associated reference
counting and orphaned objects etc that were prevalent in the COM world. .NET framework instead uses
reference tracking for garbage collector to reclaim memory from unused ...

What are Namespaces

A) Naming convention used in .NetB) Group of classes categorized to avoid name clashC) None of the
above
Latest Answer: They are the collection of pre defined classes. We can also create a user defined
namespace More Info contact: abyykurian@yahoo.co.in ...

Which of the following keyword is used along with Main function in C#

A) VirtualB) StaticC) InheritsExplanation: Main functions are always static as it runs with out any instance
Latest Answer: Ans:B) Static ...

Which of the following application need not to have an entry point

A) Console applicationB) Windows applicationC) Class ModulesExplanation: Class modules are referred by
another project which will have entry point.
Latest Answer: assemblies may or may not be executables.exe or dllclass modules had no entry pont.entry
point means public void static main() method ...

What does Main method returns in C#

A) StringB) IntegerC) FloatExplanation: Main returns either Nothing or int


Latest Answer: oh my goodness, sisira's getting annoying...by default Main returns int, unless you change it
to void. those are the only 2 things it'll return.s the answer is B of those answers given, but incomplete
answer list. ...

What happens if we refer a variable which in not initialized in C#

A) Compiler throws warning messageB) Compiler throws error messageC) Compiles the application with out
any problemExplanation: Variable needs to be initialized before use
Latest Answer: There is no veriable in a class only fields or properties. when we say variables that means
they are in a method. so it will throw a error!!! ...

Instantiating a reference object requires the use of

A) New keywordB) = OperatorC) Set keyword


Latest Answer: Ans:A) New keyword ...

Which statement is invalid with regards to Constant

A) They must be initialized when they are declaredB) The value of the constant must be computable at
compile timeC) Constants are not staticD) Constant is a variable whose value can be changed through
Latest Answer: D. The reason they are called constant is that they cannot be changed. ...

Which of the member is not a member of Object

A) Equals ( )B) GetType ( )C) ToString ( )D) Parse( )


Latest Answer: Hi Followings are the member of
System.ObjectEquals()GetHashCode()GetType()Object()ReferenceEqualsToString ...
Which of the escape sequence is used for Backspace
A) oB) aC) b
Latest Answer: Ans:C) b ...

If you need your own implementation of Equals method of object what needs to be done

A) Overload Equals methodB) Override Equals methodC) Implements Equals method


Latest Answer: You also need to override the GetHashCode method if you override the equals
method.Override the GetHashCode method to allow a type to work correctly in a hash table.Do not throw an
exception in the implementation of an Equals method. Instead, return false ...

The condition for If statement in C# is enclosed with in

A) ( )B) { }C) [ ]
Latest Answer: Ans: A, we use () to enclose the condition with if statement ...

For Each statement implicitly implements which interface

A) IEnumerableB) IcomparerC) NoneExplanation: All iterators implements Ienumerable


Latest Answer: Ans: A) IEnumerable ...

Which modifiers hides an inherited method with same signature

A) NewB) VirtualC) Sealed Explanation: New hides the inherited method which was overridden by base
class
Latest Answer: A) Ans is New...

Which of the following is wrong with regards to Out keyword

A) For Out parameters a variable can be passed which has not initializedB) If Out parameters are not
assigned a value with in the function body compiler throws errorC) The variable passed as a Out parameter
Latest Answer: The Correct Answer (C) ...

How to get the capacity of an array in C#

A) Count PropertyB) Length PropertyC) Ubound method


Latest Answer: Ans:B) Length Property ...

Array declaration in C# is done with

A) [ ]B) {}C) ( )
Latest Answer: Ans:A) [ ] ...

Which operator is used for TypeCasting

A) [ ]B) ( )C) TypeOf


Latest Answer: Ans:B) ( ) ...

If we need to compare X to a value 3 how do we do it in C#

A) If (X==3)B) If (X=3)C) If (X. equals(3) )


Latest Answer: if x is an integer then if (x==3){your code} if x is string the convert value to integer then apply
this code ...

Which of the escape sequence is used for Backspace


A) o B) a C) b
Latest Answer: Ans: C) b...

If you need your own implementation of Equals method of object what needs to be done

A) Overload Equals methodB) Override Equals methodC) Implements Equals method


Latest Answer: You also need to override the GetHashCode method if you override the equals
method.Override the GetHashCode method to allow a type to work correctly in a hash table.Do not throw an
exception in the implementation of an Equals method. Instead, return false ...

The condition for If statement in C# is enclosed with in

A) ( )B) { }C) [ ]
Latest Answer: Ans: A, we use () to enclose the condition with if statement ...

For Each statement implicitly implements which interface

A) IEnumerableB) IcomparerC) NoneExplanation: All iterators implements Ienumerable


Latest Answer: Ans: A) IEnumerable ...

Which modifiers hides an inherited method with same signature

A) NewB) VirtualC) SealedExplanation: New hides the inherited method which was overridden by base
class
Latest Answer: A) Ans is New ...

Which of the following is wrong with regards to Out keyword

A) For Out parameters a variable can be passed which has not initializedB) If Out parameters are not
assigned a value with in the function body compiler throws errorC) The variable passed as a Out parameter
Latest Answer: The Correct Answer (C) ...

How to get the capacity of an array in C#

A) Count PropertyB) Length PropertyC) Ubound method


Latest Answer: Ans:B) Length Property ...

Array declaration in C# is done with

A) [ ]B) {}C) ( )
Latest Answer: Ans:A) [ ] ...

Which operator is used for TypeCasting

A) [ ]B) ( )C) TypeOf


Latest Answer: Ans:B) ( ) ...

If we need to compare X to a value 3 how do we do it in C#

A) If (X==3)B) If (X=3)C) If (X. equals(3) )


Latest Answer: if x is an integer then if (x==3){your code} if x is string the convert value to integer then apply
this code ...

Which of the following is the correct way to instantiate an object in C#:


Skill/Topic: BeginnerA) objThis = System.CreateObject( ThisObject);B) objThis = new ThisObject();
Latest Answer: Ans:B) objThis = new ThisObject(); ...

A local C# variable declared in the for loop is in scope in

Skill/Topic: BeginnerA) Body of the for loopB) The method which includes the for loopC) Class
Latest Answer: WHERE ARE INCORRECT ANS posted? ...
What is true about readonly variable in C# code?

Skill/Topic: BeginnerA) It's the same as a constantB) It's value can be assigned only onceC) You can never
assign a value to it
Latest Answer: C) You can never assign a value to it. ...

Bool data type in C# is

Skill/Topic: BeginnerA) a value typeB) a reference type


Latest Answer: bool is a value type ...

A class type in C# is a value type

Skill/Topic: BeginnerA) YesB) NoExplanation: It is a reference type


Latest Answer: No class is a reference Type because its  stored on heap  and its
heap memory ...

A struct is a

Skill/Topic: BeginnerA) value typeB) a reference type


Latest Answer: Value type. ...

An int in C# is

Skill/Topic: BeginnerA) 16 bit unsigned integerB) 32 bit signed integerC) 64 bit integer
Latest Answer: B, C# support 32-bit signed integer ...

A char in C# is

Skill/Topic: BeginnerA) 8 bitB) 16 bitC) 32 bitExplanation: Unicode characters are supported in C#


Latest Answer: A char in c# is a 16 bit character from 0x0000 to 0xffff. However, it is not enough to state the
reason for this is UNICODE.Reason:UNICODE is capable of accessing far more than 65536 characters. In
point of fact there are more than 100,000 characters ...

String is an

Skill/Topic: BeginnerA) object typeB) reference type


Latest Answer: Any type in C# is a derivative from System.Object. So more specific answer would be that
String is a reference type as opposed to a value type. ...

Which of the following are predefined reference types in C#?

Skill/Topic: BeginnerA) intB) objectC) string


Latest Answer: The pre-defined reference types are object and string, where object is the ultimate base
class of all other types. ...

Which of the following is used to denote comments in C#?


Skill/Topic: IntermediateA) /* */B) //C) ///Explanation: /// is used from XML documentation
Latest Answer: Hey this is bs, i selected all three which is correct. ...

What is an assembly?

Skill/Topic: IntermediateA) A logical unit containing complited codeB) A collection of C# compilersC) .NET
debugger
Latest Answer: (A) is correct. An assembly is a logical unit containing compiled code ...
An assembly can be stored across multiple files?

Skill/Topic: IntermediateA) YesB) No


Latest Answer: Yes.Assembly is a collection of functionality that is built, versioned, and deployed as a single
implementation unit (as one or more files). ...

Attributes

Skill/Topic: IntermediateA) Are data typesB) Return typesC) Used to provide extra information for the
compiler
Latest Answer: Attributes are descriptive tags that provide additional information about programming
elements such as types, fields, methods, and properties. Other applications, such as the Visual Basic
compiler, can refer to the extra information in attributes to determine ...

The 'finally' keyword is supported in C#?

Skill/Topic: IntermediateA) YesB) NoExplanation: Along with the try...catch...blocks


Latest Answer: Yes used with try catch block. This part of code shall be executed before the ending of
execution of program. ...

You can derive your own classes from the base class Library

Skill/Topic: IntermediateA) TrueB) False


Latest Answer: depends on the whether base class is 'sealed'. If it is declared as 'sealed' you can't inherit
from it. If it is not marked as sealed then it is possible to derive from a class in the base class library. ...

Which tool is used to browse the classes, structs, interfaces etc. in the BCL?

Skill/Topic: IntermediateA) csc.exeB) bcl.exeC) WinCV


Latest Answer: wincv as in Windows Class View ...

To start a Thread, you call the following method

Skill/Topic: IntermediateA) Start()B) Begin()C) Jump()


Latest Answer: Start()Thread thr=new Thread(new ThreadStart(fn1));thr.Start(); ...

System is a

Skill/Topic: IntermediateA) ClassB) NamespaceC) Program


Latest Answer: Namespace ...

IF a namespace isn't supplied, which namespace does a class belong to

Skill/Topic: IntermediateA) a nameless global namespaceB) SystemC) Windows


Latest Answer: This unnamed namespace, sometimes called the global namespace, is present in every file.
Any identifier in the global namespace is available for use in a named namespace. ...

The base class Arrray belongs to the mamespace


Skill/Topic: IntermediateA) GlobalTypeB) ArraysC) System
Latest Answer: Array is the right answer ...

Namespaces are used to

Skill/Topic: IntermediateA) Separate assembliesB) Create a unique name for an assemblyC) Avoid name
clashes between data types
Latest Answer: Avoid nameclash between types ...

There can me more than 1 Main() functions in a C# program

Skill/Topic: IntermediateA) YesB) NoExplanation: While compiling we can specify which Main() function to
start in
Latest Answer: Yes , While Compiling we can specify which main to use by going to properties and setting
the startup object. ...

C# collection allows accessing an element using a unique key?

Skill/Topic: IntermediateA) KeySortB) DictC) HashTable


Latest Answer: Hashtable ...

Even if an exception hasn’t occurred, the ‘finally’ block will get executed

Skill/Topic: IntermediateA) YesB) NoExplanation: Finally block is always executed


Latest Answer: A) Yes ...

You can inherit multiple interfaces in C#

Skill/Topic: IntermediateA) TrueB) FalseExplanation: A class can inherit multiple interfaces


Latest Answer: Question should be re-written as " Can C# classes implement multiple interfaces?". I think
you implement interfaces rather than inherit them. ...

Interfaces provide implementation of methods

Skill/Topic: IntermediateA) TrueB) FalseExplanation: They only provide declaration on methods, events and
properties
Latest Answer: yes ...

Structs and classes support inheritance

Skill/Topic: IntermediateA) TrueB) FalseExplanation: Only classes can inherit. Structs can’t.

Latest Answer: Actually Interfaces are 'Implemented' & never 'Inherited'.So this sounds technically correct
that Structs does not support Inheritance.

The following type of class can’t be instantiated

Skill/Topic: IntermediateA) absoluteB) abstractC) superD) none of the above


Latest Answer: B. abstract class cannot be instantiated ...

What is a multicast delegate?

Skill/Topic: IntermediateA) a delegate having multiple handlers assigned to itB) a delegate called multiple
timesC) a delegate which has multiple implementations
Latest Answer: A delegate having multiple handlers assigned to it ...

XML documents for a C# program can be generated using


Skill/Topic: IntermediateA) /xmldoc switchB) /doc switchC) /gendoc switch
Latest Answer: /doc will generate the xml document for a C# program. ...

A virtual method can’t be over ridden

Skill/Topic: IntermediateA) TrueB) False


Latest Answer: False.The virtual keyword is needed to specify that a method should override a method (or
implementaion an abstract method) of its base class. ...

Method Overloading and Overriding are the same

Skill/Topic: IntermediateA) TrueB) FalseExplanation: Overloading is changing the behavior of a method in a


derived class, whereas overriding is having multiple methods with the same name
Latest Answer: Method overloading means having two methods with the same name but different signatures
in the same scope. These two methods may exist in the same class or one in base class and another in
derived class.Method overriding means having a different implementation ...

To change the value of a variable while debugging , the following window is used

Skill/Topic: IntermediateA) DebugB) WatchC) Immediate


Latest Answer: Immediate window ...

1. Are there some features of C# language not supported by .NET?

Skill/Topic: AdvancedA) YesB) NoExplanation: For example some instances of operator overloading!
Latest Answer: With respect to multiple inheritance, I would have to say that the answer is "mostly" that C#
does not support multiple inheritance. The "mostly" part does not take into account the .NET 3.5 and C# 3.0
extension method concepts. ...

We can call COM objects in C# using :

Skill/Topic: AdvancedA) DLLImportB) UsingDLLC) DLLCall


Latest Answer: Ans:A) DLLImport ...

A delegate in C# is similar to:

Skill/Topic: AdvancedA) COMB) a function pointerC) a pointer


Latest Answer: B) a function pointer ...

Events in C# are impltemented using:

Skill/Topic: AdvancedA) Specialized DLLsB) PointersC) Delegates


Latest Answer: C) Delegates ...

Which language is more suitable for writing extermely high performance mission critical
applications?

Which language is more suitable for writing extermely high performance mission critical applications?
Skill/Topic: AdvancedA) C#B) C++C) Visual Basic .NETExplanation: This is an area where C# lags.

Can we use pointers in C#?

Skill/Topic: AdvancedA) YesB) NoExplanation: Pointers can be used if required, but it will be unsafe code.
Latest Answer: Yes, but it will be unsafe code.
What is Boxing?
Skill/Topic: AdvancedA) conversion of reference types to value typesB) conversion of value types to
reference typesC) Encapsulating a base class
Latest Answer: B) conversion of value types to reference types ...

What is automatic memory management in .NET known as:


Skill/Topic: AdvancedA) Managed CodeB) Smart CachingC) Garbage Collection
Latest Answer: C) Garbage Collection ...

Value Types are stored on the heap ..? Is it true/False ?

Skill/Topic: AdvancedA) TrueB) False


Latest Answer: B) False ...

Reference types are stored in :

Skill/Topic: AdvancedA) the HeapB) the stackC) the hard-disk


Latest Answer: A) the Heap ...

Garbage Collector:

Skill/Topic: AdvancedA) Copies the IL code to the heapB) Destroys the pointersC) is responsible for
automatic memory management
Latest Answer: ans:C) is responsible for automatic memory management ...

You can explicitly call the garbage collector

Skill/Topic: AdvancedA) TrueB) False


Latest Answer: true, we can call GC using System.GC.Collect() method. ...

NET offers the follwing security features:

Skill/Topic: AdvancedA) Transaction based securityB) Code-based securityC) Both the aboveD) None of the
above
Latest Answer: Both..NET offers "code access security".NET offers "transaction security"
(System.Transactions) ...

Any process can be divided into multiple

Skill/Topic: AdvancedA) ProgramsB) ThreadsC) Application domains


Latest Answer: Please note the question use "divide" then it should be app domain. if it use "contain"tthen
the thread is right ...

Applications running in different App Domains can't communicate with each other:

Skill/Topic: AdvancedA) TrueB) FalseExplanation: The can communicate


Latest Answer: Application that are running in different Appplication Domaine can communicate each other.
so the answer for the above question is TRUE. ...

'Reflection' is used to

Skill/Topic: AdvancedA) Get assembly metadata using codeB) Debug C# programsC) Compile C#
programs
Latest Answer: A ...
Assemblies are of the following types:
Skill/Topic: AdvancedA) SsharedB) PrivateC) Friendly
Latest Answer: There is shared assemblies which is used for diffrenent language interpotability. ...

Manifest is an area where:


Skill/Topic: AdvancedA) the assembly code is compiledB) Debug information is a storedC) Assembly
metadata is stored
Latest Answer: (C) Menifest is an area where assembly metadat is stored ...

Assembly version information is stored in the:

Skill/Topic: AdvancedA) ManifestB) Garbage CollectorC) Heap


Latest Answer: Assembly Manifest ...

We need to register a private assembly in the Windows registry in order to use it.

Skill/Topic: AdvancedA) TrueB) FalseExplanation: We just need to copy it in the folder where the executable
is located or in a subfolder below it..
Latest Answer: Ans:B) False ...

How does a running application communicate or share data with other applicxation running
indifferent

How does a running application communicate or share data with other applicxation running indifferent
application domains?
Skill/Topic: AdvancedA) using ExceptionsB) using attributesC) using .NET remoting services.

The following namespace is used for globalization:

Skill/Topic: AdvancedA) System.GlobalizationB) System.LocalizationC) System.Locale


Latest Answer: The answer is A. The System.Globalization namespace contains classes that define culture-
related information, including the language, the country/region, the calendars in use, the format patterns for
dates, currency, and numbers, and the sort order ...

How do you deploy an assembly?

Skill/Topic: AdvancedA) Using MSI installerB) using a CAB archiveC) using XCOPYD) All of the above
Latest Answer: Ans:D) All of the above ...

We inherit a class using the following syntax:

Skill/Topic: AdvancedA) class DerivedClass: BaseClass{ }B) class DerivedClass:: BaseClass{ }C) class
BaseClass :DerivedClass { }
Latest Answer: Ans:A) class DerivedClass: BaseClass{ } ...

The correct syntax for defining a delefate is:

Skill/Topic: AdvancedA) delegate {MyMethod( int y) }B) delegate void MyMethod(int y) ;C) delegate:
MyMethod (int y)
Latest Answer: delegate: MyMethod (int y) ...

Each process in a 32 bit Windows environment has the following amount of virtual memory
available:

Skill/Topic: AdvancedA) 4 MBB) 400MBC) 4 GB


Latest Answer: Reena n Prakhar....both r right. ...

The following method is used to force the garbage collector :


Skill/Topic: AdvancedA) Garbage.CollectB) System.GC.Collect()C) Gc.Clea.Up()
Latest Answer: System.GC.Collect() ...

Unsafe code in C# can be written in the flowing block:

Skill/Topic: AdvancedA) unsafe int ThisMethod(){}B) unsafe: int ThisMethod() { }C) int ThisMethod():unsafe {
}
Latest Answer: ans: A)unsafe int ThisMethod(){} ...

Following are the collections in C#:

Skill/Topic: AdvancedA) structsB) enumC) dictionariesExplanation: Ans. b & c. a isn’t a collection . Latest
Answer: Both "struct" and "enum" are value types ...

To access attributes, the following is used:

Skill/Topic: AdvancedA) reflectionB) pointersC) collections


Latest Answer: Reflection ...

The following is the namespace used for Reflection:

Skill/Topic: AdvancedA) System.Windows.ReflectionB) System.ReflectionC) System.Features.Reflection


Latest Answer: Ans:B) System.Reflection ...

What is CTS?

Skill/Topic: BeginnerA) Common Translation systemB) Csharp Type SystemC) Common Type SystemD)
Constants Translation Specification
Latest Answer: Common Type System ...

What is CLS?

Skill/Topic: BeginnerA) Common Language SpecificationB) Common Library SystemC) Csharp Language
SpecificationD) Code Location Specification
Latest Answer: CLS is common language specification, simply a specification that defines the rules to
support language integration in such a way that programs written in any language. ...

What is CLR?

Skill/Topic: BeginnerA) Common Library ReorganizationB) Csharp Language RespecificationC) Csharp


Library RosterD) Common Language Runtime
Latest Answer: Common Language Runtime ...

What is IL?

Skill/Topic: BeginnerA) Interchangeable LibraryB) Interoperable LanguagesC) Intermediate LanguageD)


Interchangeable languages
Latest Answer: Ans:C) Intermediate Language ...

Which is the first level of compilation in the .NET languages?

Skill/Topic: BeginnerA) CLRB) ILC) Platform-specific codeExplanation: Intermediate Language


Latest Answer: Ans:B) IL ...
IL code compiles to
Skill/Topic: BeginnerA) Platform-specific Executable codeB) Byte CodeC) .NET CodeExplanation: The CLR
compiles the IL into Platform-specific Executable code
Latest Answer: Ans:A) Platform-specific Executable code ...

All the .NET languages have the following in common

Skill/Topic: BeginnerA) SyntaxB) KeywordsC) Base Class Library


Latest Answer: Base class library ...

ASP.NET web pages can be programmed in C#?

Skill/Topic: BeginnerA) YesB) No


Latest Answer: ASP. Net programs can be coded in C#. ...

From command line, a C# program can be compiled using

Skill/Topic: BeginnerA) csc.exeB) csharp.exeC) compilescs.exe


Latest Answer: The ans is csc.exe ...

You can create the following using C#

Skill/Topic: BeginnerA) class librariesB) Stand alone GUI (Windows Forms) applicationsC) ASP. NET Web
pagesD) Command Line applications
Latest Answer: you can create all four type of application through c#.just go through add new project----than
u will find there some option-1.windowapplication2.window control liberary3.crystal report application4.class
liberary5.console application6.device application as ...

The C# code files have an extension

Skill/Topic: BeginnerA) .csharpB) .csC) #


Latest Answer: Ans:B) .cs ...

Every statement in C# must end in

Skill/Topic: BeginnerA) ;B) ,C) #


Latest Answer: Ans:A); ...

There must be at least the following function in a C# program

Skill/Topic: BeginnerA) main()B) Main()C) Enter()


Latest Answer: Ans:B) Main() ...

To write a line of text to the xonsole window, we make the following call

Skill/Topic: BeginnerA) Console.WriteLine()B) console.writeline()C) System.Output()


Latest Answer: Console.WriteLine(); ...

All the C# programs must have the following statement

Skill/Topic: Beginner A) using DotNetB) using System C) include System


Latest Answer: Ans: B) using System...

The following is a correct call to the Main() function


Skill/Topic: BeginnerA) static void Main()B) static Main(void)C) Main()
Latest Answer: static void Main() ...

To read user input from the console, the following statement is used

Skill/Topic: BeginnerA) Console.ReadLine();B) Console.Input()C) System.GetuserRequest();


Latest Answer: Console.ReadLine(); ...

A code block in C# is enclosed between

Skill/Topic: BeginnerA) < >B) [ ]C) { }


Latest Answer: Ans:C) { } ...

We declare an integer variable 'x' in C# as

Skill/Topic: BeginnerA) x integer;B) integer x;C) int x;


Latest Answer: int x; ...

Can we inherit the java class in C# class,how?

Latest Answer: Java Programming language is not supported with .Net Framework hence you cannot inherit
javaclass in C# class.Also Java has JavaByte code after compiling similar to MSIL which is similar but
cannot inherit due to framework support. ...

What is indexer? where it is used plz explain

Latest Answer: Indexers Indexers permit instances of a class or struct to be indexed in the same way as
arrays. Indexers are similar to propeties except that their accessors take parameters.In the following
example, a generic class is defined and provided ...

.NET FRAMEWORK

.NET FRAMEWORK1. What is . NET Framework?The . NET Framework has two main components: the
common language runtime and the . NET Framework class library.You can think of the runtime as an agent
that manages
Latest Answer: The . NET framework is a platform over which multiple languages are running.The 2 main
components are 1. FRAMEWORK CLASS LIBRARY2. COMMON LANGUAGE RUNTIMEIt's features like
CTS provide Cross Language Interoprabality.The CLR is the main Governing body ...

How we hand sql exceptions? What is the class that handles SqlServer exceptions?

Latest Answer: SqlExceptionclass is created whenever the . NET Framework Data Provider for SQL Server
encounters an error generated from the server. (Client side errors are thrown as standard common language
runtime exceptions.) SqlException always contains at least ...

WHAT IS THE ADVANTAGE OF SERIALIZATION?

Latest Answer: Serialization in .NET allows the programmer to take an instance of an object and convert it
into a format that is easily transmittable over the network, or even stored in a database or file system. This
object will actually be an instance of a custom ...

How to fill datalist usinf XML file and how to bind it,code behind language is c#

plz give answer


Latest Answer: Ans:Hello i have written this code my project it working fine//Create datasetDataSet ds=new
DataSet()//readXml fileds.readXml(Server.MapPath("*.xml"))//Create datalist objectlet'sprotected
System.Web.UI.WebControls.DataList DataList1;//here bind the dataSource ...

What is the difference between const and static read-only?


The difference is that static read-only can be modified by the containing class, but const can never be
modified and must be initialized to a compile time constant. To expand on the static read-only case
Latest Answer: As static read-only variables must be initialized in the static constructor (static constructor
cannot have parameters and it cannot be called manually), it is efficient to used const variables over static
read-only variables if you know the values ...

Is it mandatory to implement all the methods which are there in abstract class if we inherit that
abstract

Is it mandatory to implement all the methods which are there in abstract class if we inherit that abstract
class..?

Why do I get a "CS5001: does not have an entry point defined" error when compiling?

The most common problem is that you used a lowercase 'm' when defining the Main method. The correct
way to implement the entry point is as follows: class test {static void Main(string[] args)
Latest Answer: class test { public test() { } public static void Main(string[] args) {} } modifier for Main is
public and inside the clas default constructor is necessary ...

What's the implicit name of the parameter that gets passed into the class' set method?

Value, and its datatype depends on whatever variable we're changing.


Latest Answer: Ans: Value :parameter gets passed into the class' set method ...

How do you inherit from a class in C#?

Place a colon and then the name of the base class. Notice that it's double colon in C++.
Latest Answer: Lets us say there are 2 claases , Class A and ClassB.ClassA -BaseClass,ClassB-derived
class ClassA{}ClassB:ClassA(baseclass){}here we can say ClassB is derived from classA.Hope this is
right. ...
Read Answers (2)

Answer Question Subscribe

Does C# support multiple inheritance?

No, use interfaces instead.


Latest Answer: c# does not support multiple inheritance ...
Read Answers (2)
Tags : Inheritance

Answer Question Subscribe

When you inherit a protected class-level variable, who is it available to?

Classes in the same namespace.


Latest Answer: Classes (sub) dervied from the class (parent) where the protected class-level variable is
defined. ...

Are private class-level variables inherited?

Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they
are.
Latest Answer: Yes, but they are not accessible ...

Describe the accessibility modifier protected internal.

It's available to derived classes and classes within the same Assembly (and naturally from the base class it's
declared in).
Latest Answer: ans: It's available to derived classes and classes within the same Assembly (and naturally
from the base class it's declared in). ...

C# provides a default constructor for me. I write a constructor that takes a string as a parameter,

C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to
keep the no parameter one. How many constructors should I write?
Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write
one yourself, even if there's no implementation in it.

What's the top .NET class that everything is derived from?


System.Object.
Latest Answer: Ans:System.Object ...

How's method overriding different from overloading?

When overriding, you change the method behavior for a derived class. Overloading simply involves having a
method with the same name within the class.
Latest Answer: overriding keyword cahnge behavour in derive class with same signature,Overloading
means same name but passing different datatype or different number arguments within the same class ...

What does the keyword virtual mean in the method definition?

The method can be over-ridden.


Latest Answer: If a base class have a virtual method it means that method must be override by the derived
class using override keyword. ...

What is an abstract class?

A class that cannot be instantiated. A concept in C++ known as pure virtual method. A class that must be
inherited and have the methods over-ridden. Essentially, it is a blueprint for a class without
Latest Answer: Abstarct Class:Abstract class is a class, which consist at least one pure virtuall function. a
pure virtual fuction is a fuction with no body and ia declered with the keyword Virtual and initialised to zero
(0). ex: virtual void Display()=0;here ...

What is the data provider name to connect to Access database?

Microsoft.Access.
Latest Answer: it is System.Data.OleDb .. ...

What is the implicit name of the parameter that gets passed into the class set method?

Value, and its datatype depends on whatever variable we are changing.


Latest Answer: Ans:value is implicit name of the parameter that gets passed into the class set method. ...

How do you inherit from a class in C#?


Place a colon and then the name of the base class. Notice that it is double colon in C++.
Latest Answer: let's you have 2classes Class A is the base classClass B is the derived classClass B:A is
the syntax to inherit a base class ...

Does C# support multiple inheritance?

No, use interfaces instead.


Latest Answer: No, Instead of this, we can inheritance the multiple interface,but C++ support multiple
inheritance ...

When you inherit a protected class-level variable, who is it available to?

Classes in the same namespace.


Latest Answer: Protected level variable is available to only sub classes(i.e class inherited from this base
class). ...

Are private class-level variables inherited?

Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they
are.
Latest Answer: Private members of the base class are not directly available to the derived class, so we can
say that they are not inherited. However the private variables can be manipulated via the base class
methods which are declared as protected or public. ...

Describe the accessibility modifier protected internal.


It is available to derived classes and classes within the same Assembly (and naturally from the base class it
is declared in).
Latest Answer: Ans:protected internal is available to derived classes and classes within the same Assembly
(and naturally from the base class it is declared in). function checkf(form) { var f = document.form1;if
(document.form1.cmt.value=='') { alert('Please enter ...

C# provides a default constructor for me. I write a constructor that takes a string as a parameter,

C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to
keep the no parameter one. How many constructors should I write?
Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write
one yourself, even if there is no implementation in it.

What is the top .NET class that everything is derived from?

System.Object.
Latest Answer: Ans:System.Objects ...

How is method overriding different from overloading?

When overriding, you change the method behavior for a derived class. Overloading simply involves having a
method with the same name within the class.
Latest Answer: Overriding a method involves changing the business logic og the method, however the return
type and parameters remain same. However in overloading a method you can have multiple methods with
same name but different signatures. ...

What does the keyword virtual mean in the method definition?


The method can be over-ridden.
Latest Answer: Keyword virtual is used to make changes to the methods inside the virtual class while
runtime. the virtual class should be overide with the same modifier, return type and the name. ...
Can you declare the override method static while the original method is non-static?
No, you cannot, the signature of the virtual method must remain the same, only the keyword virtual is
changed to keyword override.
Latest Answer: No you cannot declare the override method static while original method is non-static, not
even vice versa. ...

Can you override private virtual methods?

No, moreover, you cannot access private methods in inherited classes, have to be protected in the base
class to allow any sort of access.
Latest Answer: Yes samikcs is correct we cannot declare a method as 'private virtual'.Virtual is used to
ovveride this method in the derived class. ...

Can you prevent your class from being inherited and becoming a base class for some other
classes?

Yes, that is what keyword sealed in the class definition is for. The developer trying to derive from your class
will get a message: cannot inherit from Sealed class WhateverBaseClassName. It is the same
Latest Answer: can be done by using the keyword "not inhertitable "syntax is not inheritable class
'''''''''''''''codeend class ...

Can you allow class to be inherited, but prevent the method from being over-ridden?

Yes, just leave the class public and make the method sealed.
Latest Answer: Yes, do not put "virtual" on the base method. ...

When do you absolutely have to declare a class as abstract (as opposed to free-willed educated
choice

When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or
decision based on UML diagram)?
When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract
class, but not all base abstract methods have been over-ridden.

What is an interface class?


It is an abstract class with public abstract methods all of which must be implemented in the inherited
classes.
Latest Answer: Ans:Definition:An Interface is a reference type and it contains only abstract members.
Interface's members can be Events, Methods, Properties and Indexers. But the interface contains only
declaration for its members.The interface can't contain constants, ...

Why cannot you specify the accessibility modifier for methods inside the interface?

They all must be public. Therefore, to prevent you from getting the false impression that you have any
freedom of choice, you are not allowed to specify any accessibility, it is public by default.
Latest Answer: Ans:No,because by default method are public. ...

Can you inherit multiple interfaces?

Yes.
Latest Answer: Ans:Yes ...

What is the difference between an interface and abstract class?

In the interface all methods must be abstract; in the abstract class some methods can be concrete. In the
interface no accessibility modifiers are allowed, which is ok in abstract classes.
Latest Answer: Abstract classes act as the buliding block whose object cannot be created. We include
common functionality in abstract class which can inherited by the sub classes. They are not 100% abstract
whereas interface provide 100% abstraction in this no function ...

How can you overload a method?

Different parameter data types, different number of parameters, different order of parameters.
Latest Answer: A method can be overloaded by having different parameters as in different type of
parameters and well different number of parameters.Also, if the parameter types are different than you can
also have different return type.example :you can have public int ...

If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of

If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of
overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base
constructor?
Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the
overloaded constructor definition inside the inherited class.

What is the difference between System.String and System.StringBuilder classes?

System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string
where a variety of operations can be performed.
Latest Answer: Answer: System.String is immutable; System.StringBuilder was designed with the purpose of
having a mutable string where a variety of operations can be performed. function checkf(form) { var f =
document.form1;if (document.form1.cmt.value=='') { alert('Please ...

What is the advantage of using System.Text.StringBuilder over System.String?

StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are
immutable, so each time it is being operated on, a new instance is created.
Latest Answer: Ans:Yes,it is right.Answer: StringBuilder is more efficient in the cases, where a lot of
manipulation is done to the text. Strings are immutable, so each time it is being operated on, a new instance
is created. function checkf(form) { var f = document.form1;if ...

Can you store multiple data types in System.Array?

No.
Latest Answer: Ans:No ...

What is the difference between the System.Array.CopyTo() and System.Array.Clone()?

The first one performs a deep copy of the array, the second one is shallow.
Latest Answer: I felt the need of this posting because I have seen postings (not only in this forum but also in
many others) saying that "CopyTo() makes a deep copy and Clone() makes a shallow copy." This is
absolutely wrong.Both CopyTo() and Clone() ...
How can you sort the elements of the array in descending order?
By calling Sort() and then Reverse() methods.
Latest Answer: first sort elements of array in ascending order using appropriate sorting
technique( BUBBLE,HEAP,QUICK..........)AFTER sorting scan array in reverse order ie and store it. ...

What is the .NET datatype that allows the retrieval of data by a unique key?

HashTable. What is class SortedList underneath?


Latest Answer: A ns:HasTable ...

Will finally block get executed if the exception had not occurred?

Yes. What is the C# equivalent of C++ catch (…), which was a catch-all statement for any possible
exception?
Latest Answer: Yes, the final block gets executed the order of the execution is:Try block, Catch block and
Finally block. ...

Can multiple catch blocks be executed?

No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and
then whatever follows the finally block.
Latest Answer: No: only one catch block will be executed for an exception. We can write several catch
blocks below a try block. When an exception generates all these catch blocks will be scanned sequentially
for a matching exception type. It is advised to write catch ...

What is a delegate?

A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.
Latest Answer: A typical example of delegate usage can be found in event handling. For example, when the
event is raised that the selected index of a dropdown list changed, we want method
"ddlFoo_SelectedIndexChanged(object sender, EventArgs e)" to be ...

What is a multicast delegate?

It is a delegate that points to and eventually fires off several methods.


Latest Answer: Ans:Yes, It is a delegate that points to and eventually fires off several methods. ...

How is the DLL Hell problem solved in .NET?

Assembly versioning allows the application to specify not only the library it needs to run (which was available
under Win32), but also the version of the assembly.
Latest Answer: Ans:solve by Assembly version ...

What are the ways to deploy an assembly?

An MSI installer, a CAB archive, and XCOPY command.


Latest Answer: Ans:An MSI installer, a CAB archive, and XCOPY command. ...

What is a satellite assembly?


When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application
separately from the localized modules, the localized assemblies that modify the core application
Latest Answer: An satellite assembly is a (.dll)file which contain localized resources for the
application.Satellite assembly is created for each culture.So an application can contain as many satellite
based on the currentUI culture setting. ...

What namespaces are necessary to create a localized application?

System.Globalization, System.Resources.
Latest Answer: Ans:using System.Threading ; Using System.Globalization ;using System.Resources; ...

What is the difference between // comments, /* */ comments and /// comments?


Single-line, multi-line and XML documentation comments.
Latest Answer: // Is for Single-Line Comments./* */ Is for Multi-Line Comments./// For XML
Documentation Comments ...

How do you generate documentation from the C# file commented properly with a command-line
compiler?

Compile it with a /doc switch.


Latest Answer: Ans:Compile it with the /doc switch. ...

What is the difference between and XML documentation tag?

Single line code example and multiple-line code example.


Latest Answer: Ans:Single line code example and multiple-line code example. ...

Is XML case-sensitive?

Yes, so and are different elements.


Latest Answer: Ans:Yes,Xml is case sensitive ...

What debugging tools come with the .NET SDK?

CorDBG - command-line debugger, and DbgCLR - graphic debugger. Visual Studio .NET uses the DbgCLR.
To use CorDbg, you must compile the original C# file using the /debug switch.
Latest Answer: Ans:CorDBG - command-line debugger, and DbgCLR - graphic debugger. Visual Studio
.NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch. ...

What does the This window show in the debugger?

It points to the object that is pointed to by this reference. Object’s instance data is shown.
Latest Answer: Ans:It points to the object that is pointed to by this reference. Object’s instance data is shown
...

What does assert() do?

In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the
condition is false. The program proceeds without any interruption if the condition is true.
Latest Answer: Ans:In debug compilation, assert takes in a Boolean condition as a parameter, and shows
the error dialog if the condition is false. The program proceeds without any interruption if the condition is
true. ...
What is the difference between the Debug class and Trace class?

Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and
release builds.
Latest Answer: the Debug and the Trace classes are available in the Microsoft .NET Framework. You can
use these classes to provide information about the performance of an application either during application
development, or after deployment to production. ...

Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

The tracing dumps can be quite verbose and for some applications that are constantly running you run the
risk of overloading the machine and the hard drive there. Five levels range from None to Verbose,
Latest Answer: Ans:The tracing dumps can be quite verbose and for some applications that are constantly
running you run the risk of overloading the machine and the hard drive there. Five levels range from None to
Verbose, allowing to fine-tune the tracing activities. ...

Where is the output of TextWriterTraceListener redirected?

To the Console or a text file depending on the parameter passed to the constructor.
Latest Answer: Answer: To the Console or a text file depending on the parameter passed to the
constructor. ...
How do you debug an ASP.NET Web application?
Attach the aspnet_wp.exe process to the DbgClr debugger.
Latest Answer: Ans:Yes, Attach the aspnet_wp.exe process to the DbgClr debugger. ...

What are three test cases you should go through in unit testing?

Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper
handling), exception test cases (exceptions are thrown and caught properly).
Latest Answer: Ans:Yes,It is corect.Positive test cases (correct data, correct output), negative test cases
(broken or missing data, proper handling), exception test cases (exceptions are thrown and caught
properly). ...

Can you change the value of a variable while debugging a C# application?

Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.
Latest Answer: Yes. Go to immediate window in VS.net and use >eval var = newvalue ...

Explain the three services model (three-tier application).

Presentation (UI), business (logic and underlying code) and data (from storage or other sources). Latest
Answer: Ans:1.Presentation (UI), 2.business (logic and underlying code) and 3.data access layer(from
storage or other sources). ...

What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?

SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from
Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access
Latest Answer: Ans:Advantage:SQLServer.NET data provider is high-speed and robust.DisAdvantage.but
requires SQL Server license purchased from Microsoft ...

What is the role of the DataReader class in ADO.NET connections?


It returns a read-only dataset from the data source when the command is executed.
Latest Answer: DataReader Class represents a read-only and forward-only stream of data.An instance of
this class is used to hold the data returned by executing the Select statement in the DBCommand object
using Executereader() method of the DBCommand Class. ...

What is the wildcard character in SQL?

Let us say you want to query database with LIKE for all employees whose name starts with La. The wildcard
character is %, the proper query with LIKE would involve La%.
Latest Answer: Ans:The wildcard character is Like operator ...

Explain ACID rule of thumb for transactions.

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
Latest Answer: Ans:ACID:ExpandingA:AtomicTransaction must be Atomic (it is one unit of work and does
not dependent on previous and following transactions)C:ConsistentConsistent (data is either committed or
roll back, no “in-between” case where something has been updated ...

What connections does Microsoft SQL Server support?

Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server
username and passwords).
Latest Answer: Ans:Windows Authentication (via Active Directory) and SQL Server authentication (via
Microsoft SQL Server username and passwords). ...

Which one is trusted and which one is untrusted?

Windows Authentication is trusted because the username and password are checked with the Active
Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating
Latest Answer: ans:Trusted Windows Authentication is trusted because the username and password are
checked with the Active Directory.Untrusted.the SQL Server authentication is untrusted, since SQL Server is
the only verifier participating in the transaction.
Why would you use untrusted verificaion?
Web Services might use it, as well as non-Windows applications.
Latest Answer: Ans:Yes, Web Services mightuse it, as well as non-Windows applications. ...

What does the parameter Initial Catalog define inside Connection String?

The database name to connect to.


Latest Answer: ans:Initial Catalog="databasename" ...

What does Dispose method do with the connection object?

Deletes it from the memory.


Latest Answer: It is important to note that connection.Dispose() actually closes the connection first.Hence I
believe it is the preferred method of destroying a connection. Given that one should really Dispose anything
that implements Dispose. eg otherwise ...

What is a pre-requisite for connection pooling?


Multiple processes must agree that they will share the same connection, where every parameter is the
same,
Latest Answer: also have the same security configuration ...

Why does DllImport not work for me?

All methods marked with the DllImport attribute must be marked as public static extern.
Latest Answer: It works perfectly. You can find the dialogue window by using "ALT+Tab" keyRobert ...

My switch statement works differently! Why?

C# does not support an explicit fall through for case blocks. The following code is not legal and will not
compile in C#: switch(x){case 0:// do somethingcase 1:// do something in common with 0default://
Latest Answer: c# switch allows fall through if and only if in empty case. as long as there is a statement in
the case it must use break or go to to jump out of the case. ...

How do I do implement a trace and assert?

Use a conditional attribute on the method, as shown below: class Debug{[conditional("TRACE")]public void
Trace(string s){Console.WriteLine(s);}}class MyClass{public static void Main(){Debug.Trace("hello");}}In
Latest Answer: Well, you cant add the namespace System.Diagnostics.ConditionalAttribute. Actually you
need to add the namespace System.Diagnostics and capitalise "Conditional" like so:using System;using
System.Diagnostics;namespace Debug{ class ...

How do I make a DLL in C#?

You need to use the /target:library compiler option.


Latest Answer: There is no Issue to make dll in C#...Go to Project and Select "Class Library" and work as
you work in Usual FORM by making Classes or functions ....The only difference is that when we are making
any File in DLL ,The file cannot be run in Class ...

Why do I get a syntax error when trying to declare a variable called checked?

The word checked is a keyword in C#.


Latest Answer: Reason is checked is a keyword in C#,but if u want to keyword as an identifier use @ with
it.e.g int @checked=3;This works with all the keywords,but it is recommended to avoid it. ...

What is the syntax for calling an overloaded constructor within a constructor (this() and
constructorname()

What is the syntax for calling an overloaded constructor within a constructor (this() and constructorname()
does not compile)?
The syntax for calling another constructor is as follows: class B{B(int i){ }}class C : B{C() : base(5) // call
base constructor B(5){ }C(int i) : this() // call C(){ }public static void Main() {}}

Is there an equivalent to the instanceof operator in Visual J++?


C# has the is operator: expr is type
Latest Answer: EX:==============using System; class ClassA {} public class TestIs{ public static void
Test (object o) { ClassA a = null; if (o is ClassA) ...

Why do I get an error (CS1006) when trying to declare a method without specifying a return type?
If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a
constructor. So if you are trying to declare a method that returns nothing, use void. The following
Latest Answer: If your method does not have any return type then mention void before that method or return
0 ...

Does Console.WriteLine() stop printing when it reaches a NULL character within a string?

Strings are not null terminated in the runtime, so embedded nulls are allowed. Console.WriteLine() and all
similar methods continue until the end of the string.
Latest Answer: Console.WriteLine() stop printing when it reaches a 'Carriage Return' (denotes next
line)Â character within a string! ...

How do I create a Delegate/MulticastDelegate?

C# requires only a single parameter for delegates: the method address. Unlike other languages, where the
programmer must specify an object reference and the method to invoke, C# can infer both pieces of
Latest Answer: This article is good.IntroductionIn this article I am going to share my knowledge on
Delegates in C#.This would explain the Delegate using simple examples so that the beginner can
understand the same.What is Delegate?Definition:Delegate is type which ...

Why does my Windows application pop up a console window every time I run it?

Make sure that the target type set in the project properties setting is set to Windows Application, and not
Console Application. If you're using the command line, compile with /target:winexe &
Latest Answer: Compile with following syntax at command line : csc /t:winexe ...

Is there a way to force garbage collection?

Yes. Set all references to null and then call System.GC.Collect().If you need to have some objects
destructed, and System.GC.Collect() doesn't seem to be doing it for you, you can force finalizers
Latest Answer: GC.Collect();It is recomended that you should not forcefully call the GC. GC does it in the
optimal way, since it knows the inner details like which object actually created inner objects.But some case
you may need to force GC to free the scarce memory ...

Does C# support C type macros?

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,
Latest Answer: Ans:No ...

How do you directly call a native function exported from a DLL?

Here's a quick example of the DllImport attribute in action: using System.Runtime.InteropServices;class


C{[DllImport("user32.dll")]public static extern int MessageBoxA(int h, string m, string
Latest Answer: ans:by using1st:using System.Runtime.InteropServicessecond
step[DllImport("user32.dll")]use top of the class ...

Does C# support templates?

No. However, there are plans for C# to support a type of template known as a generic. These generic types
have similar syntax but are instantiated at run time as opposed to compile time. You can read more
Latest Answer: Generics are a new feature in version 2.0 of the C# language and the common language
runtime (CLR). Generics introduce to the .NET Framework the concept of type parameters, which make it
possible to design classes and methods that defer the specification ...

I was trying to use an "out int" parameter in one of my functions. How should I declare the

I was trying to use an "out int" parameter in one of my functions. How should I declare the variable that I am
passing to it?
You should declare the variable as an int, but when you pass it in you must specify it as 'out', like the
following: int i;foo(out i);where foo is declared as follows: [return-type] foo(out int

The following is a correct call to the Main() function


Skill/Topic: BeginnerA) static void Main()B) static Main(void)C) Main()
Latest Answer: static void Main() ...

To read user input from the console, the following statement is used

Skill/Topic: BeginnerA) Console.ReadLine();B) Console.Input()C) System.GetuserRequest();


Latest Answer: Console.ReadLine(); ...

A code block in C# is enclosed between

Skill/Topic: BeginnerA) < >B) [ ]C) { }


Latest Answer: Ans:C) { } ...

We declare an integer variable 'x' in C# as

Skill/Topic: BeginnerA) x integer;B) integer x;C) int x;


Latest Answer: int x; ...

Can we inherit the java class in C# class,how?

Latest Answer: Java Programming language is not supported with .Net Framework hence you cannot inherit
javaclass in C# class.Also Java has JavaByte code after compiling similar to MSIL which is similar but
cannot inherit due to framework support. ...

What is indexer? where it is used plz explain

Latest Answer: Indexers Indexers permit instances of a class or struct to be indexed in the same way as
arrays. Indexers are similar to propeties except that their accessors take parameters.In the following
example, a generic class is defined and provided ...

.NET FRAMEWORK

.NET FRAMEWORK1. What is . NET Framework?The . NET Framework has two main components: the
common language runtime and the . NET Framework class library.You can think of the runtime as an agent
that manages
Latest Answer: The . NET framework is a platform over which multiple languages are running.The 2 main
components are 1. FRAMEWORK CLASS LIBRARY2. COMMON LANGUAGE RUNTIMEIt's features like
CTS provide Cross Language Interoprabality.The CLR is the main Governing body ...

How we hand sql exceptions? What is the class that handles SqlServer exceptions?
Latest Answer: SqlExceptionclass is created whenever the . NET Framework Data Provider for SQL Server
encounters an error generated from the server. (Client side errors are thrown as standard common language
runtime exceptions.) SqlException always contains at least ...

WHAT IS THE ADVANTAGE OF SERIALIZATION?

Latest Answer: Serialization in .NET allows the programmer to take an instance of an object and convert it
into a format that is easily transmittable over the network, or even stored in a database or file system. This
object will actually be an instance of a custom ...

How to fill datalist usinf XML file and how to bind it,code behind language is c#

plz give answer


Latest Answer: Ans:Hello i have written this code my project it working fine//Create datasetDataSet ds=new
DataSet()//readXml fileds.readXml(Server.MapPath("*.xml"))//Create datalist objectlet'sprotected
System.Web.UI.WebControls.DataList DataList1;//here bind the dataSource ...

How do you debug an ASP.NET Web application?


Attach the aspnet_wp.exe process to the DbgClr debugger.
Latest Answer: Ans:Yes, Attach the aspnet_wp.exe process to the DbgClr debugger. ...

What are three test cases you should go through in unit testing?

Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper
handling), exception test cases (exceptions are thrown and caught properly).
Latest Answer: Ans:Yes,It is corect.Positive test cases (correct data, correct output), negative test cases
(broken or missing data, proper handling), exception test cases (exceptions are thrown and caught
properly). ...

Can you change the value of a variable while debugging a C# application?

Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.
Latest Answer: Yes. Go to immediate window in VS.net and use >eval var = newvalue ...

Explain the three services model (three-tier application).

Presentation (UI), business (logic and underlying code) and data (from storage or other sources).
Latest Answer: Ans:1.Presentation (UI), 2.business (logic and underlying code) and 3.data access
layer(from storage or other sources). ...

What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?

SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from
Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access
Latest Answer: Ans:Advantage:SQLServer.NET data provider is high-speed and robust.DisAdvantage.but
requires SQL Server license purchased from Microsoft ...

What is the role of the DataReader class in ADO.NET connections?

It returns a read-only dataset from the data source when the command is executed.
Latest Answer: DataReader Class represents a read-only and forward-only stream of data.An instance of
this class is used to hold the data returned by executing the Select statement in the DBCommand object
using Executereader() method of the DBCommand Class. ...
What is the wildcard character in SQL?

Let us say you want to query database with LIKE for all employees whose name starts with La. The wildcard
character is %, the proper query with LIKE would involve La%.
Latest Answer: Ans:The wildcard character is Like operator ...

Explain ACID rule of thumb for transactions.

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
Latest Answer: Ans:ACID:ExpandingA:AtomicTransaction must be Atomic (it is one unit of work and does
not dependent on previous and following transactions)C:ConsistentConsistent (data is either committed or
roll back, no “in-between” case where something has been updated ...

What connections does Microsoft SQL Server support?

Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server
username and passwords).
Latest Answer: Ans:Windows Authentication (via Active Directory) and SQL Server authentication (via
Microsoft SQL Server username and passwords). ...

Which one is trusted and which one is untrusted?

Windows Authentication is trusted because the username and password are checked with the Active
Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating
Latest Answer: ans:Trusted Windows Authentication is trusted because the username and password are
checked with the Active Directory.Untrusted.the SQL Server authentication is untrusted, since SQL Server is
the only verifier participating in the transaction. ...
Why would you use untrusted verificaion?
Web Services might use it, as well as non-Windows applications.
Latest Answer: Ans:Yes, Web Services mightuse it, as well as non-Windows applications. ...

What does the parameter Initial Catalog define inside Connection String?

The database name to connect to.


Latest Answer: ans:Initial Catalog="databasename" ...

What does Dispose method do with the connection object?

Deletes it from the memory.


Latest Answer: It is important to note that connection.Dispose() actually closes the connection first.Hence I
believe it is the preferred method of destroying a connection. Given that one should really Dispose anything
that implements Dispose. eg otherwise ...

What is a pre-requisite for connection pooling?

Multiple processes must agree that they will share the same connection, where every parameter is the
same,
Latest Answer: also have the same security configuration ...

Why does DllImport not work for me?

All methods marked with the DllImport attribute must be marked as public static extern.
Latest Answer: It works perfectly. You can find the dialogue window by using "ALT+Tab" keyRobert ...

My switch statement works differently! Why?

C# does not support an explicit fall through for case blocks. The following code is not legal and will not
compile in C#: switch(x){case 0:// do somethingcase 1:// do something in common with 0default://
Latest Answer: c# switch allows fall through if and only if in empty case. as long as there is a statement in
the case it must use break or go to to jump out of the case. ...

How do I do implement a trace and assert?

Use a conditional attribute on the method, as shown below: class Debug{[conditional("TRACE")]public void
Trace(string s){Console.WriteLine(s);}}class MyClass{public static void Main(){Debug.Trace("hello");}}In
Latest Answer: Well, you cant add the namespace System.Diagnostics.ConditionalAttribute. Actually you
need to add the namespace System.Diagnostics and capitalise "Conditional" like so:using System;using
System.Diagnostics;namespace Debug{ class ...

How do I make a DLL in C#?

You need to use the /target:library compiler option.


Latest Answer: There is no Issue to make dll in C#...Go to Project and Select "Class Library" and work as
you work in Usual FORM by making Classes or functions ....The only difference is that when we are making
any File in DLL ,The file cannot be run in Class ...

Why do I get a syntax error when trying to declare a variable called checked?

The word checked is a keyword in C#.


Latest Answer: Reason is checked is a keyword in C#,but if u want to keyword as an identifier use @ with
it.e.g int @checked=3;This works with all the keywords,but it is recommended to avoid it. ...

What is the syntax for calling an overloaded constructor within a constructor (this() and
constructorname()

What is the syntax for calling an overloaded constructor within a constructor (this() and constructorname()
does not compile)?
The syntax for calling another constructor is as follows: class B{B(int i){ }}class C : B{C() : base(5) // call
base constructor B(5){ }C(int i) : this() // call C(){ }public static void Main() {}}
Is there an equivalent to the instanceof operator in Visual J++?
C# has the is operator: expr is type
Latest Answer: EX:==============using System; class ClassA {} public class TestIs{ public static void
Test (object o) { ClassA a = null; if (o is ClassA) ...

Why do I get an error (CS1006) when trying to declare a method without specifying a return type?

If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a
constructor. So if you are trying to declare a method that returns nothing, use void. The following
Latest Answer: If your method does not have any return type then mention void before that method or return
0 ...

Does Console.WriteLine() stop printing when it reaches a NULL character within a string?
Strings are not null terminated in the runtime, so embedded nulls are allowed. Console.WriteLine() and all
similar methods continue until the end of the string.
Latest Answer: Console.WriteLine() stop printing when it reaches a 'Carriage Return' (denotes next
line)Â character within a string! ...

How do I create a Delegate/MulticastDelegate?

C# requires only a single parameter for delegates: the method address. Unlike other languages, where the
programmer must specify an object reference and the method to invoke, C# can infer both pieces of
Latest Answer: This article is good.IntroductionIn this article I am going to share my knowledge on
Delegates in C#.This would explain the Delegate using simple examples so that the beginner can
understand the same.What is Delegate?Definition:Delegate is type which ...

Why does my Windows application pop up a console window every time I run it?

Make sure that the target type set in the project properties setting is set to Windows Application, and not
Console Application. If you're using the command line, compile with /target:winexe &
Latest Answer: Compile with following syntax at command line : csc /t:winexe ...

Is there a way to force garbage collection?

Yes. Set all references to null and then call System.GC.Collect().If you need to have some objects
destructed, and System.GC.Collect() doesn't seem to be doing it for you, you can force finalizers
Latest Answer: GC.Collect();It is recomended that you should not forcefully call the GC. GC does it in the
optimal way, since it knows the inner details like which object actually created inner objects.But some case
you may need to force GC to free the scarce memory ...

Does C# support C type macros?

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,
Latest Answer: Ans:No ...

How do you directly call a native function exported from a DLL?

Here's a quick example of the DllImport attribute in action: using System.Runtime.InteropServices;class


C{[DllImport("user32.dll")]public static extern int MessageBoxA(int h, string m, string
Latest Answer: ans:by using1st:using System.Runtime.InteropServicessecond
step[DllImport("user32.dll")]use top of the class ...

Does C# support templates?

No. However, there are plans for C# to support a type of template known as a generic. These generic types
have similar syntax but are instantiated at run time as opposed to compile time. You can read more
Latest Answer: Generics are a new feature in version 2.0 of the C# language and the common language
runtime (CLR). Generics introduce to the .NET Framework the concept of type parameters, which make it
possible to design classes and methods that defer the specification ...

I was trying to use an "out int" parameter in one of my functions. How should I declare the

I was trying to use an "out int" parameter in one of my functions. How should I declare the variable that I am
passing to it?
You should declare the variable as an int, but when you pass it in you must specify it as 'out', like the
following: int i;foo(out i);where foo is declared as follows: [return-type] foo(out int

How do I declare inout arguments in C#?


The equivalent of inout in C# is ref. , as shown in the following example: public void MyMethod (ref String
str1, out String str2) {...}When calling the method, it would be called like this: String s1; String
Latest Answer: Ans: Answer: The equivalent of inout in C# is ref. , as shown in the following example: public
void MyMethod (ref String str1, out String str2) {...}When calling the method, it would be called like this:
String s1; String s2;s1 = "Hello";MyMethod(ref s1, ...

How do destructors and garbage collection work in C#?

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{~C(){// your code}public static void Main()
Latest Answer: If you are not declare any Main() method in your program then compiler will give you this
errors. Basically Main() is the entry point for compiler for execution. One more thing C# ia a case sensitive
language so be carefull about the spelling of Main() ...

How do I port "synchronized" functions from Visual J++ to C#?

Original Visual J++ code: public synchronized void Run() {// function body}Ported C# code: class C{public
void Run(){lock(this){// function body }}public static void Main() {}}

How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#?

You want the lock statement, which is the same as Monitor Enter/Exit: lock(obj) {// code}translates to: try
{CriticalSection.Enter(obj);// code} finally {CriticalSection.Exit(obj);}
Latest Answer: A thread is simply a separate stream of execution that takes place simultaneously with and
independently of everything else that might be happening. A thread can synchronize itself with another
thread waiting for it to complete.The System.Threading.Thread ...

Is it possible to have different access modifiers on the get/set methods of a property?

No. The access modifier on a property applies to both its get and set accessors. What you need to do if you
want them to be different is make the property read-only (by only providing a get accessor) and
Latest Answer: yes,it is possible for get and set to have different access modifiers,but one of the accessors
must follow the access level of property. ...

How do I create a multilanguage, single-file assembly?

This is currently not supported by Visual Studio .NET.


Latest Answer: It is not possible ...

Does C# support properties of array types?

Yes. Here's a simple example: using System; class Class1 {private string[] MyField;public string[]
MyProperty {get { return MyField; }set { MyField = value; }}}class MainClass{public static int Main(string[]
Latest Answer: yes u can use indexer.its working is same as properties. ...

How do I create a multilanguage, multifile assembly?


Unfortunately, this is currently not supported in the IDE. To do this from the command line, you must compile
your projects into netmodules (/target:module on the C# compiler), and then use the command
Latest Answer: Ans:Unfortunately, this is currently not supported in the IDE. To do this from the command
line, you must compile your projects into netmodules (/target:module on the C# compiler), and then use the
command line tool al.exe (alink) to link these netmodules ...

How do I simulate optional parameters to COM calls?

You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have
optional parameters.
Latest Answer: Ans:Yes,it is right. Answer: You must use the Missing class and pass Missing.Value (in
System.Reflection) for any values that have optional parameters. ...

Is there a way of specifying which block or loop to break out of when working with nested loops?

The easiest way is to use goto: using System; class BreakExample {public static void Main(String[] args)
{for(int i=0; i

Latest Answer: Yes, there are ways to break out of nested loops. Although GOTO is allowed in C#, it is
normally a bad idea, bad style, and indication of lack of good software development foundation of those who
use it (no offense intended).Here are a couple of

How do I get deterministic finalization in C#?


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.

How do I convert a string to an int in C#?

Here's an example: using System; class StringToInt{public static void Main(){String s = "105";int x =
Convert.ToInt32(s);Console.WriteLine(x);}}
Latest Answer: Ans:by using onvert.ToInt32(string)ExampleString s = "45";int x = Convert.ToInt32(s); ...

Is there an equivalent of exit() for quitting a C# .NET application?

Yes, you can use System. Environment.Exit(int exitCode) to exit the application or Application.Exit() if it's a
Windows Forms app.
Latest Answer: Ans:YesSystem. Environment.Exit(int exitCode) to exit the application or Application.Exit() if
it's a Windows Forms app. ...

How do you specify a custom attribute for the entire assembly (rather than for a class)?

Global attributes must appear after any top-level using clauses and before the first type or namespace
declarations. An example of this is as follows: using System;[assembly : MyAttributeClass] class X
Latest Answer: ans:Yes,it is right. ...

How do I register my code for use by classic COM clients?

Use the regasm.exe utility to generate a type library (if needed) and the necessary entries in the Windows
Registry to make a class available to classic COM clients. Once a class is registered in the Windows
Latest Answer: ans: using regasm.exe utility ...

How does one compare strings in C#?


In the past, you had to call .ToString() on the strings when using the == or != operators to compare the
strings' values. That will still work, but the C# compiler now automatically compares the values
Latest Answer: You can use a.Equals(b) to compare and return a bool value where both a and b are
strings. ...

Can I define a type that is an alias of another type (like typedef in C++)?

Not exactly. You can create an alias within a single file with the "using" directive: using System;using Integer
= System.Int32; // aliasBut you can't create a true alias, one that extends
Latest Answer: Ans:by using statement keyword ...

What is the difference between a struct and a class in C#?

From language spec:The list of similarities between classes and structs is as follows. Longstructs can
implement interfaces and can have the same kinds of members as classes. Structs differ from classes
Latest Answer: Following are the main points of difference between classes and structs in C#:Value type vs
Reference type: Structs are value type and classes are reference type. Whenever a struct object is assigned
to another struct object a copy is created. In case ...

How can I get the ASCII code for a character in C#?

Casting the char to an int will give you the ASCII value: char c = 'f';System.Console.WriteLine((int)c);or for a
character in a string: System.Console.WriteLine((int)s[3]);The base class libraries
Latest Answer: Ans:// Create an ASCII encoding. Encoding ascii = Encoding.ASCII;The base class
libraries also offer ways to do this with the Convert class or Encoding classes if you need a particular ...

From a versioning perspective, what are the drawbacks of extending an interface as opposed to
extending

From a versioning perspective, what are the drawbacks of extending an interface as opposed to extending a
class?
With regard to versioning, interfaces are less flexible than classes. With a class, you can ship version 1 and
then, in version 2, decide to add another method. As long as the method is not abstract (i.e.,

Is it possible to inline assembly or IL in C# code?


No.
Latest Answer: Ans:Yes ...

Is it possible to restrict the scope of a field/method of a class to the classes in the same
namespace?

Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace?
There is no way to restrict to a namespace. Namespaces are never units of protection. But if you're using
assemblies, you can use the 'internal' access modifier to restrict access to only

If I return out of a try/finally in C#, does the code in the finally-clause run?

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
Latest Answer: Ans:Yes ...
Does C# support try-catch-finally blocks?

Yes. Try-catch-finally blocks are supported by the C# compiler. Here's an example of a try-catch-finally
block: using System;public class TryTest{static void Main(){try{Console.WriteLine("In
Latest Answer: Ans: yes...

Is it possible to have a static indexer in C#?

No. Static indexers are not allowed in C#.


Latest Answer: Ans:No ...

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

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

How can I access the registry from C# code?

By using the Registry and Registry Key classes in Microsoft.Win32, you can easily access the registry. The
following is a sample that reads a key and displays its value: using System;using Microsoft.Win32;class
Latest Answer: Ans:By using the Registry and Registry Key classes in Microsoft.Win32 ...

Does C# support #define for defining global constants?

No. If you want to get something that works like the following C code:#define A 1use the following C# code:
class MyConstants{public const int A = 1;}Then you use MyConstants.A where you would otherwise
Answer: Ans: No...

How can I create a process that is running a supplied native executable (e.g., cmd.exe)?

The following code should run the executable and wait for it to exit before continuing: using System;using
System.Diagnostics;public
class ProcessTest
{
public static void Main(string[] args)
{
Process p = Process.Start(args[0]);
p.WaitForExit();

Console.WriteLine(args[0] + " exited.");

}}

How do you mark a method obsolete?

Assuming you've done a "using System;": [Obsolete]public int Foo() {...}or [Obsolete("This is a message
describing why this method is obsolete")]public int Foo() {...}Note: The
: Ans: By using Obsolete Keyword...

Is there any sample C# code for simple threading?

Is there regular expression (regex) support available to C# developers?


Yes. The .NET class libraries provide support for regular expressions. Look at the documentation for the
System.Text.RegularExpressions namespace.
Latest Answer: Ans: Yes...

Why do I get a security exception when I try to run my C# app?

Some security exceptions are thrown if you are working on a network share. There are some parts of the
frameworks that will not run if being run off a share (roaming profile, mapped drives, etc.). To see if this is
what's happening, just move the executable over to your local drive and see if it runs without the exceptions.
One of the common exceptions thrown under these conditions is System.Security.SecurityException.

To get around this, you can change your security policy for the intranet zone, code group 1.2, (the zone that
running off shared folders falls into) by using the caspol.exe tool.

How can I get around scope problems in a try/catch?

If you try to instantiate the class inside the try, it'll be out of scope when you try to access it from the catch
block. A way to get around this is to do the following:

What is the equivalent to regsvr32 and regsvr32 /u a file in .NET development?

Try using RegAsm.exe. The general syntax would be: RegAsm. A good description of RegAsm and its
associated switches is located in the .NET SDK docs. Just search on "Assembly Registration Tool".
ans:regasm.exe ...

Does C# support parameterized properties?

No. C# does, however, support the concept of an indexer from language spec. An indexer is a member that
enables an object to be indexed in the same way as an array. Whereas properties enable field-like
Answer: No...

Potrebbero piacerti anche