Saturday, March 6, 2010

C# and Dot Net Interview Questions III

How to find exceptions in database
If program successfully complie . but program is not run or execute.then give an exception.

How can objects be late bound in .NET?
Instead of using new keyword we can use create object like in this example we are creating object to write in excel sheet through our programexampleImports Excel = Microsoft.Office.Interop.ExcelPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim objApp As Object Dim objBook As Object Dim objBooks As Object Dim objSheets As Object Dim objSheet As Object Dim range As Object ‘ Instantiate Excel and start a new workbook. objApp = CreateObject(”Excel.Application”) objBooks = objApp.Workbooks objBook = objBooks.Add objSheets = objBook.Worksheets objSheet = objSheets.Item(1) range = objSheet.Range(”A1″) ‘Set the range value. range.Value = “Hello, World!” ‘Return control of Excel to the user. objApp.Visible = True objApp.UserControl = TrueEnd Sub

Where we can use DLL made in C#.Net
Supporting .Net, bcoz DLL made in C#.Net semicompiled version. Its not a com object. It is used only in .Net Framework.As it is to be compiled at runtime to byte code.

What Datatypes does the RangeValidator Control support?
String, Integer, Double, Date, Currency

Constructor is the method which is implicitly created when ever a class is instantiated. Why?
Constructors are class methods that are executed when an object of a given type is created. Constructors have the same name as the class, and usually initialize the data members of the new object

Why multiple Inheritance is not possible in C#?
Multiple Inheritance is possible in C++, but its not possible in Java, and C#.
what we are read above those are all we know, but as per my knowledge, in C++ to resolve multiple inheritance we are using “this pointer”. But in C# there is no pointer concept. In such way, the architectures using the interface concept. To resolving the ambiguity “this pointer” concept used in c++.
Offcourse it not absolutely correct, but its my idea only. If you are agree with my view then follow it, else leave it.

Why strings are immutable?
1) In VB6.0 and c++ strings are simple array of bytes, but in .Net it is class System.String and is immutable.
2) A string is a sequential collection of Unicode characters, which usually is used to represent text. A String, on the other hand, is a .NET Framework class (System.String) that represents a Unicode string with a sequential collection of System.Char structure.

How to convert ocx into DLL
you cannot convert OCX to dll becoz dll do not have GUI interfaces .IF your ocx does not have GUI and you have convert manuly by cut and paste from OCX to Dll project

What is the main difference between pointer and delegate with examples?
A Delegate in c# allows to pass a method of class to object of other class.
Rules in Deligation:-
1.In order to create a Delegate a Signature(parameter) must match Signature of object.
2.Define all the methods which has the same Signature as Deligate define.
3.Create the deligate object & pass the method as a parameter to Deligate.
4.Now call the encapsulated method using deligated object.
the best example of Deligation modle is ADO.NET Architecture & Event Handling in windows environament.

How do i read the information from web.config file?
string ConStrFromWeb=System.Configuration.ConfigurationSettings.AppSettings[”ConStringKey”];
// Here ConStringKey is the key name of connection string in web.config


What is the default Function arguments?
Default function argument is a function argument with a default value. Callers of this function have a choice whether to pass a value for default argument or not. If a function call passes a value for default argument it is used as its value. If a function call does not pass a value the default value specified in the function definition is used.
A function may have any number of default arguments. However all these arguments must follow all mandatory arguments. That is first you have to specify all non-default or mandatory parameters and then all default parameters.

No comments:

Post a Comment