Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
C# Serializable Keyword
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". ...
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 ...
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
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) ...
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 ...
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
Design Patterns
'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. ...
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: ...
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. ...
intushortdecimalenum
Latest Answer: sbyte(System.SByte)ushort(System.UInt16)uint(System.UInt32)ulong(System.UInt64)are
non-cls compliant . ...
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
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. ...
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, ...
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
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
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.
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...
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 ...
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 ...
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 ...
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 ...
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, ...
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]; 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 ...
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. ...
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.
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. ...
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.
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 ...
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 ...
Latest Answer: square of value at memory whose address is defined by ptr. ...
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. ...
Latest Answer: Hi All, The different types of access modifiers are 1. private 2. public
Latest Answer: Yes - using System; public class Parent{ string parentString; public Parent() {
Console.WriteLine("Parent Constructor."); } ...
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.
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?
Which debugging window allows you to see the methods called in the order they were called?
Which debugging window allows you to see all the name and values of all the variables in scope?
Latest Answer: Auto, Local, Watch ...
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#. ...
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! ...
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++
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 ...
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 ...
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 ...
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.
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?
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.
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 ...
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. ...
Latest Answer: C# does not support optional arguments.you can use function overloading to achieve the
same. ...
Latest Answer: IsNothing is only used in VB or VB.NET. someone is really confused ...
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). ...
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, ...
By declaring a base class function as virtual we allow the function to be overridden in subclasses
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 ...
A) TrueB) False
Latest Answer: Interface members are implicitly public, explicit modifiers are not allowed. ...
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. ...
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 ...
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 ...
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
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 ...
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 ...
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.
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. ...
A) Making class as AbstractB) Having a Private constructorC) Making the class sealedD) Both A & B
Latest Answer: private contructor ...
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 ...
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.
.Net Remoting doesn’t allow creating stateless & stateful Remote objects
A) TrueB) False
Latest Answer: ans:B) False ...
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
A) YesB) NoC) It depends on how we declare themExplanation: Static methods cannot be overridable
Latest Answer: No ...
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. ...
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. ...
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 ...
A) Source CodeB) Managed CodeC) Unmanaged CodeExplanation: Source code is compiled to MSIL,
which is generally known as managed code
Latest Answer: Managed Code ...
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. ...
A) TrueB) FalseExplanation: AS the managed code is bound to CTS & CLS it is language interoperable
Latest Answer: Ans:A) True ...
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 ...
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? ...
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. ...
.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 ...
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 ...
A) VirtualB) StaticC) InheritsExplanation: Main functions are always static as it runs with out any instance
Latest Answer: Ans:B) Static ...
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 ...
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!!! ...
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. ...
If you need your own implementation of Equals method of object what needs to be done
A) ( )B) { }C) [ ]
Latest Answer: Ans: A, we use () to enclose the condition with if statement ...
A) NewB) VirtualC) Sealed Explanation: New hides the inherited method which was overridden by base
class
Latest Answer: A) Ans is New...
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) ...
A) [ ]B) {}C) ( )
Latest Answer: Ans:A) [ ] ...
If you need your own implementation of Equals method of object what needs to be done
A) ( )B) { }C) [ ]
Latest Answer: Ans: A, we use () to enclose the condition with if statement ...
A) NewB) VirtualC) SealedExplanation: New hides the inherited method which was overridden by base
class
Latest Answer: A) Ans is New ...
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) ...
A) [ ]B) {}C) ( )
Latest Answer: Ans:A) [ ] ...
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. ...
A struct is a
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
String is an
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?
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 ...
You can derive your own classes from the base class Library
Which tool is used to browse the classes, structs, interfaces etc. in the BCL?
System is a
Skill/Topic: IntermediateA) Separate assembliesB) Create a unique name for an assemblyC) Avoid name
clashes between data types
Latest Answer: Avoid nameclash between types ...
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. ...
Even if an exception hasn’t occurred, the ‘finally’ block will get executed
Skill/Topic: IntermediateA) TrueB) FalseExplanation: They only provide declaration on methods, events and
properties
Latest Answer: yes ...
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.
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 ...
To change the value of a variable while debugging , the following window is used
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. ...
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.
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 ...
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 ...
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) ...
Applications running in different App Domains can't communicate with each other:
'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. ...
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.
Skill/Topic: AdvancedA) Using MSI installerB) using a CAB archiveC) using XCOPYD) All of the above
Latest Answer: Ans:D) All of the above ...
Skill/Topic: AdvancedA) class DerivedClass: BaseClass{ }B) class DerivedClass:: BaseClass{ }C) class
BaseClass :DerivedClass { }
Latest Answer: Ans:A) class DerivedClass: BaseClass{ } ...
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) unsafe int ThisMethod(){}B) unsafe: int ThisMethod() { }C) int ThisMethod():unsafe {
}
Latest Answer: ans: A)unsafe int ThisMethod(){} ...
Skill/Topic: AdvancedA) structsB) enumC) dictionariesExplanation: Ans. b & c. a isn’t a collection . Latest
Answer: Both "struct" and "enum" are value types ...
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?
What is IL?
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 ...
To write a line of text to the xonsole window, we make the following call
To read user input from the console, the following statement is used
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. ...
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 ...
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#
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?
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)
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 ...
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.
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 ...
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 ...
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?
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. ...
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.
System.Object.
Latest Answer: Ans:System.Objects ...
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. ...
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.
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. ...
Yes.
Latest Answer: Ans:Yes ...
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 ...
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.
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 ...
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 ...
No.
Latest Answer: Ans:No ...
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?
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. ...
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 ...
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 ...
System.Globalization, System.Resources.
Latest Answer: Ans:using System.Threading ; Using System.Globalization ;using System.Resources; ...
How do you generate documentation from the C# file commented properly with a command-line
compiler?
Is XML case-sensitive?
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. ...
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
...
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. ...
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. ...
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). ...
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 ...
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 ...
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 ...
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 ...
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). ...
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?
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 ...
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. ...
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 ...
Why do I get a syntax error when trying to declare a variable called checked?
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() {}}
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! ...
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 ...
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 ...
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 ...
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
To read user input from the console, the following statement is used
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. ...
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 ...
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#
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). ...
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 ...
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 ...
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 ...
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 ...
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). ...
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?
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 ...
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 ...
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. ...
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 ...
Why do I get a syntax error when trying to declare a variable called checked?
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! ...
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 ...
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 ...
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 ...
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
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() ...
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() {}}
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 ...
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. ...
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. ...
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
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); ...
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. ...
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 ...
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 ...
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 ...
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 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...
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
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 ...
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();
}}
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...
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.
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:
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 ...
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...