Saturday, 5 July 2014

C# Interview

1. What is MSIL CODE?
2. Why .net plat form dependent.
3. What is Abstact class, interface.
Basic structure of interface.
4. How we can do exception handling in c#.net
5. What is dispose and finally methods?
6. What is collections, diff b/w array list and
7. Generics
Ex:
MyCustomList student = new MyCustomList();

8. Diff b/w Convert.toInt and int.parse
9. Using dataset how to bind to grid sample code
10. AutoEventWireup=”true”
Ans) The ASP.NET page framework supports an automatic way to associate page events and methods. If the AutoEventWireup attribute of the Page directive is set to true, the page framework calls page events automatically, specifically the Page_Init and Page_Load methods. In that case, no explicit Handles clause or delegate is needed.
• AutoEventWireup is an attribute in Page directive.
• AutoEventWireup is a Boolean attribute that indicates whether the ASP.NET pages events are auto-wired.
• AutoEventWireup will have a value true or false. By default it is true.
There is no event or method associated with Page_Load. Those events whose inline event is not there but that should be executed, for that purposed AutoEventWireup=”true”.
11. What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
Data Base
How to call another server table through current server in sql
Ans) Method 1 : Remote Stored Procedure can be called as four part name:
Syntax:
EXEC [RemoteServer] .DatabaseName.DatabaseOwner.StoredProcedureName
‘Params’
Example:
EXEC [DEVSQL] .AdventureWorks.dbo.uspGetEmployeeManagers ’42′
Method 2 : Use Distributed Query functions (OpenQuery())
Syntax: SELECT *
FROM OPENQUERY([RemoteServer],DatabaseName.DatabaseOwner.StoredProcedureName)
Example: SELECT *
FROM OPENQUERY([DEVSQL],AdventureWorks.dbo.spAdmin_GetAllUsers)
Let me know if you want me write about above two methods in detail.
How many types of temp tables are there in sql
Ans) # local temporary table, ## global temporary table
You’ll notice I prefixed the table with a pound sign (#). This tells SQL Server that this table is a local temporary table. This table is only visible to this session of SQL Server. When I close this session, the table will be automatically dropped. You can treat this table just like any other table with a few exceptions. The only real major one is that you can’t have foreign key constraints on a temporary table.
You can also create global temporary tables. These are named with two pound signs. For example, ##YakHerders is a global temporary table. Global temporary tables are visible to all SQL Server connections. When you create one of these, all the users can see it. These are rarely used in SQL Server.
Write a query to get 2nd maximum salary in an employee table
What is cross Join?
Ans) SQL CROSS JOIN will return all records where each row from the first table is combined with each row from the second table. Which also mean CROSS JOIN returns the Cartesian product of the sets of rows from the joined tables.
A CROSS JOIN can be specified in two ways: using the JOIN syntax or by listing the tables in the FROM clause separated by commas without using a WHERE clause to supply join criteria.
SQL CROSS JOIN syntax:
SELECT * FROM [TABLE 1] CROSS JOIN [TABLE 2]
OR
SELECT * FROM [TABLE 1], [TABLE 2]
What inner join do?
A) The INNER JOIN keyword return rows when there is at least one match in both tables.
SQL LEFT JOIN
A) The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2).
SQL RIGHT JOIN
A) The RIGHT JOIN keyword Return all rows from the right table (table_name2), even if there are no matches in the left table (table_name1).
create table uname
(
id int,
uname varchar(10)
)
create trigger insert_Uname
on uname
for insert
as
declare @nm varchar(10)
select @nm = uname from inserted
print @nm
What is the Magic Tables in Sqlserver2000?
Ans) When u r creating the table at the same time two tables(Insert table, Delete Table) r created automatically at the backend. It is Magic Table