Home
C-Sharp
Interview FAQs

Show

FAQs of level

A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
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.

Throwing your own exceptions signifies some design flaws in the project. If you throw your exception which means you know that an error has occurred, then  the question arise that why not write the proper code to handle that error instead of passing a new Exception object to the catch block? 

There are five access specifiers available in c#-

  • Private 
  • Protected
  • Public
  • Internal
  • Protected Internal.

We need to serialize the object, if you want to pass object from one computer/application domain to another. Process of converting complex objects into stream of bytes that can be persisted or transported. Namespace for serialization is System.Runtime.Serialization. The ISerializable interface allows you to make any class Serializable. .Net framework provides two serialization method-

  1. Binary Serialization 
  2. XML Serialization

By using following code we achieve this task-
Response.Write(Request.ServerVariables ("SERVER_SOFTWARE"));

The term managed is the cause of much confusion. It is used in various places within .Net, meaning slightly different things.

Managed code: The .Net framework provides several core run-time services to the programs that run within it - for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. Such code is called managed code. All C# and Visual Basic.Net code is managed by default. 

Managed data: This is data that is allocated and deallocated by the .Net runtimes garbage collector. C# and VB.Net data is always managed.

Managed classes: This is usually referred to in the context of Managed Extensions  for C++. When using C++, a class can be marked with the _gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector, but it also means more than that. The class becomes a fully paid-up member of the .Net community with the benefits and restrictions that brings. An example of a benefit is proper interop with classes written in other languages - for example, a managed C++ class can inherit from a VB class. An example of a restriction is that a managed class can only inherit from one base class.

Dictionary is a generic type, Hashtable is not. That means you get type safety with Dictionary, because you can not insert any random object into it, and you do not have to cast the values you take out. Since both Dictionary and Hashtable are internally hashtables, so fast access to many-item data according to key, also both need immutable and unique keys. 

Both lists and dictionaries are used to store collections of data. The Dictionary is based on a hash table, that means it uses a hash lookup, which is a rather efficient algorithm to look up things, on the other hand, a list you have to go element by element until it finds the result from beginning to the result each time. 
Following is a full source code of adding and retrieving key values pairs in Dictionary-
Dictionary < string, int > dict = new Dictionary < string, int > ();
dict.Add("one", 1);
dict.Add("two", 2);
dict.Add("three", 3);
dict.Add("four", 4);
foreach (KeyValuePair < string, int >  pair in dict)
{
MessageBox.Show(pair.Key.ToString() + "  -  " + pair.Value.ToString());
}

An extender provider is a component that provides properties to other components.
Implementing an extender provider:

  • Use the ProvidePropertyAttribute, which specifies the name of the property that an implementer of IExtenderProvider provides to other components, attribute to specify the property provided by your extender provider.
  • Implement the provided property.
  • Track which controls receive your provided property.
  • Implement the IExtenderProvider, which defines the interface for extending properties to other components in a containe, interface.

PreviousDisplaying 23 of 25Next
Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*