<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2enclosuresfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Dot Net</title><link>http://bytescode.blogspot.com/</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/blogspot/qiWo" /><description></description><language>en</language><managingEditor>noreply@blogger.com (ZeroCode)</managingEditor><lastBuildDate>Thu, 21 Apr 2011 12:54:32 PDT</lastBuildDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">35</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">25</openSearch:itemsPerPage><feedburner:info uri="blogspot/qiwo" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><itunes:explicit>no</itunes:explicit><itunes:subtitle>Dot Net</itunes:subtitle><item><title>oops-77</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/S3czmdXrYms/oops-77.html</link><category>OOPS</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Wed, 13 Feb 2008 04:12:25 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-9049555149791831332</guid><description>1))What happens when you encounter a continue statement inside the for loop?&lt;br /&gt;ans))The code for the rest of the loop is ignored, the control is transferred back to the beginning of the loop. &lt;br /&gt;&lt;br /&gt;2))Is goto statement supported in C#? How about Java?&lt;br /&gt;ans))Gotos are supported in C# to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality. &lt;br /&gt;&lt;br /&gt;3))How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#?&lt;br /&gt;ans))You want the lock statement, which is the same as Monitor Enter/Exit:&lt;br /&gt;lock(obj)&lt;br /&gt;{&lt;br /&gt;// code&lt;br /&gt;}&lt;br /&gt;translates to: try&lt;br /&gt;{&lt;br /&gt;CriticalSection.Enter(obj);&lt;br /&gt;// code&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;CriticalSection.Exit(obj);&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;4))How do I make a DLL in C#?&lt;br /&gt;ans&gt;&gt;You need to use the /target:library compiler option &lt;br /&gt;&lt;br /&gt;5))How do I simulate optional parameters to COM calls?&lt;br /&gt;ans&gt;&gt;You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters. &lt;br /&gt;&lt;br /&gt;6))Does C# support try-catch-finally blocks?&lt;br /&gt;ans&gt;&gt;&lt;br /&gt;Yes. Try-catch-finally blocks are supported by the C# compiler.Here’s an example of a try-catch-finally block: using System;&lt;br /&gt;public class TryTest&lt;br /&gt;{&lt;br /&gt; static void Main()&lt;br /&gt;{&lt;br /&gt; try&lt;br /&gt; {&lt;br /&gt; Console.WriteLine(”In Try block”);&lt;br /&gt; throw new ArgumentException();&lt;br /&gt; }&lt;br /&gt; catch(Argument7))Is there a way to force garbage collection?&lt;br /&gt; Exception n1)&lt;br /&gt; {&lt;br /&gt; Console.WriteLine(”Catch Block”);&lt;br /&gt; }&lt;br /&gt; finally&lt;br /&gt;{&lt;br /&gt; Console.WriteLine(”Finally Block”);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;Output: In Try Block&lt;br /&gt;Catch Block&lt;br /&gt;Finally Block &lt;br /&gt;7))Is there a way to force garbage collection?&lt;br /&gt;ans&gt;&gt;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 to be run by setting all the references to the object to null and then calling System.GC.RunFinalizers(). &lt;br /&gt;&lt;br /&gt;8))Is XML case-sensitive?&lt;br /&gt;ans&gt;&gt;Yes, so and are different elements. &lt;br /&gt;&lt;br /&gt;9))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?&lt;br /&gt;ans&gt;&gt;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. &lt;br /&gt;&lt;br /&gt;10))Can you allow class to be inherited, but prevent the method from being over-ridden?&lt;br /&gt;Categories: C# Interview Questions ?&lt;br /&gt;ans&gt;&gt;Yes, just leave the class public and make the method sealed &lt;br /&gt;&lt;br /&gt;11))Can you change the value of a variable while debugging a C# application?&lt;br /&gt;ans&gt;&gt;Yes, if you are debugging via Visual Studio.NET, just go to Immediate window. &lt;br /&gt;&lt;br /&gt;12))A DataSet transmits data through which one of the following?  &lt;br /&gt;&lt;br /&gt;ans&gt;&gt;XML file&lt;br /&gt;Explanation : Transmitting an ADO.NET dataset between applications is much easier than transmitting an ADO disconnected recordset. To transmit an ADO disconnected recordset from one component to another, you use COM marshalling. To transmit data in ADO.NET, you use a dataset, which can transmit an XML stream. &lt;br /&gt;&lt;br /&gt;13))Can abstract class be inherited?&lt;br /&gt;&lt;br /&gt;ans&gt;&gt; Yes&lt;br /&gt;14))What is the maximum number of columns allowed for an Index? &lt;br /&gt;&lt;br /&gt;ans&gt;&gt;3. 16&lt;br /&gt;&lt;br /&gt;15))What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?&lt;br /&gt;The Clone() method returns a new array&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-9049555149791831332?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-02-13T04:12:25.650-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2008/02/oops-77.html</feedburner:origLink></item><item><title>Examples:1 Gridview</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/jQcIhFhHLvI/example-aspnet-with-xml.html</link><category>ASP.NET</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Fri, 28 Dec 2007 23:32:41 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-6773245751388902459</guid><description>protected void ParentGridView_OnRowEditing(object sender, GridViewEditEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        int parent_index = e.NewEditIndex;&lt;br /&gt;        &lt;br /&gt;        //to set the edit index of the Parent grid with that of the current row&lt;br /&gt;        ParentGridView.EditIndex = parent_index;&lt;br /&gt;        ParentGridView.DataBind();&lt;br /&gt;        //find the pubid_lbl containing pub_id in that particular row by using findcontrol method&lt;br /&gt;        GridViewRow row = ParentGridView.Rows[parent_index];&lt;br /&gt;        Label pub_id_lbl = (Label)row.FindControl("pubid_lbl");&lt;br /&gt;       &lt;br /&gt;        //save pub_id and edit_index in session for childgridview's use&lt;br /&gt;        Session["PubID"] = Convert.ToInt32(pub_id_lbl.Text);&lt;br /&gt;        Session["ParentGridViewIndex"] = parent_index;&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;    protected void ChildGridView_OnRowEditing(object sender, GridViewEditEventArgs e)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        //set the edit index of the child gridview with that of the current row&lt;br /&gt;        int parent_index =(int)Session["ParentGridViewIndex"];&lt;br /&gt;        GridViewRow parent_row = ParentGridView.Rows[parent_index];&lt;br /&gt;        GridView ChildGridiView = (GridView)parent_row.FindControl("ChildGridView");&lt;br /&gt;&lt;br /&gt;        int child_index = e.NewEditIndex;&lt;br /&gt;        ChildGridiView.EditIndex = child_index;&lt;br /&gt;        ChildGridiView.DataBind();&lt;br /&gt;        //find the titleid_lbl in that particular row by using findcontrol method&lt;br /&gt;        GridViewRow child_row = ChildGridiView.Rows[child_index];&lt;br /&gt;        Label titleid_lbl = (Label)child_row.FindControl("titleid_lbl");&lt;br /&gt;        // save the title_id in session for grandchildgridview's use&lt;br /&gt;        Session["TitleID"] = titleid_lbl.Text;&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-6773245751388902459?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-28T23:32:41.846-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/example-aspnet-with-xml.html</feedburner:origLink></item><item><title>sql-Questions</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/5N_HhJNLUaA/sql-questions.html</link><category>Security</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Wed, 26 Dec 2007 02:37:01 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-6705488495764933528</guid><description>1        What is BCP? When do we use it? - BulkCopy is a tool used to copy huge amount of data from tables and views. But it won’t copy the structures of the same.&lt;br /&gt;2        What should we do to copy the tables, schema and views from one SQL Server to another? &lt;br /&gt;      We have to write some DTS packages for it.&lt;br /&gt;3        What are the different types of joins and what dies each do?&lt;br /&gt;4        What are the four main query statements?&lt;br /&gt;5        What is a sub-query? When would you use one?&lt;br /&gt;6        What is a NOLOCK?&lt;br /&gt;7        What are three SQL keywords used to change or set someone’s permissions?&lt;br /&gt;8        What is the difference between HAVING clause and the WHERE clause?&lt;br /&gt;9        What is referential integrity? What are the advantages of it?&lt;br /&gt;10   What is database normalization?&lt;br /&gt;11   Which command using Query Analyzer will give you the version of SQL server and operating system?&lt;br /&gt;12   Using query analyzer, name 3 ways you can get an accurate count of the number of records in a table?&lt;br /&gt;13   What is the purpose of using COLLATE in a query?&lt;br /&gt;14   What is a trigger?&lt;br /&gt;15   What is one of the first things you would do to increase performance of a query? For example, a boss tells you that “a query that ran yesterday took 30 seconds, but today it takes 6 minutes”&lt;br /&gt;16   What is an execution plan? When would you use it? How would you view the execution plan?&lt;br /&gt;17   What is the STUFF function and how does it differ from the REPLACE function?&lt;br /&gt;18   What does it mean to have quoted_identifier on? What are the implications of having it off?&lt;br /&gt;19   What are the different types of replication? How are they used?&lt;br /&gt;20   What is the difference between a local and a global variable?&lt;br /&gt;21   What is the difference between a Local temporary table and a Global temporary table? How&lt;br /&gt;      is each one used?&lt;br /&gt;22   What are cursors? Name four types of cursors and when each one would be applied?&lt;br /&gt;23   What is the purpose of UPDATE STATISTICS?&lt;br /&gt;24   How do you use DBCC statements to monitor various aspects of a SQL server installation?&lt;br /&gt;25   How do you load large data to the SQL server database?&lt;br /&gt;26   How do you check the performance of a query and how do you optimize it?&lt;br /&gt;27   How do SQL server 2000 and XML linked? Can XML be used to access data?&lt;br /&gt;28   What is SQL server agent?&lt;br /&gt;29   What is referential integrity and how is it achieved?&lt;br /&gt;30   What is indexing?&lt;br /&gt;31   What is normalization and what are the different forms of normalizations?&lt;br /&gt;32   Difference between server.transfer and server.execute method?&lt;br /&gt;33   What id de-normalization and when do you do it?&lt;br /&gt;34   What is better - 2nd Normal form or 3rd normal form? Why?&lt;br /&gt;35   Can we rewrite subqueries into simple select statements or with joins? Example?&lt;br /&gt;36   What is a function? Give some example?&lt;br /&gt;37   What is a stored procedure?&lt;br /&gt;38   Difference between Function and Procedure-in general?&lt;br /&gt;39   Difference between Function and Stored Procedure?&lt;br /&gt;40   Can a stored procedure call another stored procedure. If yes what level and can it be&lt;br /&gt;      controlled?&lt;br /&gt;41   Can a stored procedure call itself(recursive). If yes what level and can it be controlled.?&lt;br /&gt;42   How do you find the number of rows in a table?&lt;br /&gt;43   Difference between Cluster and Non-cluster index?&lt;br /&gt;44   What is a table called, if it does not have neither Cluster nor Non-cluster Index?&lt;br /&gt;45   Explain DBMS, RDBMS?&lt;br /&gt;46   Explain basic SQL queries with SELECT from where Order By, Group By-Having?&lt;br /&gt;47   Explain the basic concepts of SQL server architecture?&lt;br /&gt;48   Explain couple pf features of SQL server&lt;br /&gt;49   Scalability, Availability, Integration with internet, etc.)?&lt;br /&gt;50   Explain fundamentals of Data ware housing &amp;amp; OLAP?&lt;br /&gt;51   Explain the new features of SQL server 2000?&lt;br /&gt;52   How do we upgrade from SQL Server 6.5 to 7.0 and 7.0 to 2000?&lt;br /&gt;53   What is data integrity? Explain constraints?&lt;br /&gt;54   Explain some DBCC commands?&lt;br /&gt;55   Explain sp_configure commands, set commands?&lt;br /&gt;56   Explain what are db_options used for?&lt;br /&gt;57   What is the basic functions for master, msdb, tempdb databases?&lt;br /&gt;58   What is a job?&lt;br /&gt;59   What are tasks?&lt;br /&gt;60   What are primary keys and foreign keys?&lt;br /&gt;61   How would you Update the rows which are divisible by 10, given a set of numbers in&lt;br /&gt;      column?&lt;br /&gt;62   If a stored procedure is taking a table data type, how it looks?&lt;br /&gt;63   How m-m relationships are implemented?&lt;br /&gt;64   How do you know which index a table is using?&lt;br /&gt;65   How will oyu test the stored procedure taking two parameters namely first name and last&lt;br /&gt;      name returning full name?&lt;br /&gt;66   How do you find the error, how can you know the number of rows effected by last SQL&lt;br /&gt;      statement?&lt;br /&gt;67   How can you get @@error and @@rowcount at the same time?&lt;br /&gt;68   What are sub-queries? Give example? In which case sub-queries are not feasible?&lt;br /&gt;69   What are the type of joins? When do we use Outer and Self joins?&lt;br /&gt;70   Which virtual table does a trigger use?&lt;br /&gt;71   How do you measure the performance of a stored procedure?&lt;br /&gt;72   Questions regarding Raiseerror?&lt;br /&gt;73   Questions on identity?&lt;br /&gt;74   If there is failure during updation of certain rows, what will be the state?&lt;br /&gt;75   SQL Server interview questions&lt;br /&gt;76   How do you read transaction logs?&lt;br /&gt;77   How do you reset or reseed the IDENTITY column?&lt;br /&gt;78   How do you persist objects, permissions in tempdb?&lt;br /&gt;79   How do you simulate a deadlock for testing purposes?&lt;br /&gt;80   How do you rename an SQL Server computer?&lt;br /&gt;81   How do you run jobs from T-SQL?&lt;br /&gt;82   How do you restore single tables from backup in SQL Server 7.0/2000? In SQL Server 6.5?&lt;br /&gt;83   Where to get the latest MDAC from?&lt;br /&gt;84   I forgot/lost the sa password. What do I do?&lt;br /&gt;85   I have only the .mdf file backup and no SQL Server database backups. Can I get my&lt;br /&gt;      database back into SQL Server?&lt;br /&gt;86   How do you add a new column at a specific position (say at the beginning of the table or&lt;br /&gt;      after the second column) using ALTER TABLE command?&lt;br /&gt;87   How do you change or alter a user defined data type?&lt;br /&gt;88   How do you rename an SQL Server 2000 instance?&lt;br /&gt;89   How do you capture/redirect detailed deadlock information into the error logs?&lt;br /&gt;90   How do you remotely administer SQL Server?&lt;br /&gt;91   What are the effects of switching SQL Server from ‘Mixed mode’ to ‘Windows only’&lt;br /&gt;      authentication mode? What are the steps required, to not break existing applications?&lt;br /&gt;92   Is there a command to list all the tables and their associated filegroups?&lt;br /&gt;93   How do you ship the stored procedures, user defined functions (UDFs), triggers, views of&lt;br /&gt;my application, in an encrypted form to my clients/customers? How do you protect intellectual property?&lt;br /&gt;94   How do you archive data from my tables? Is there a built-in command or tool for this?&lt;br /&gt;95   How do you troubleshoot ODBC timeout expired errors experienced by applications&lt;br /&gt;      accessing SQL Server databases?&lt;br /&gt;96   How do you restart SQL Server service automatically at regular intervals?&lt;br /&gt;97   What is the T-SQL equivalent of IIF (immediate if/ternary operator) function of other&lt;br /&gt;      programming languages?&lt;br /&gt;98   How do you programmatically find out when the SQL Server service started? How do you get rid of the time part from the date returned by GETDATE function&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-6705488495764933528?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-26T02:37:01.767-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/sql-questions.html</feedburner:origLink></item><item><title>sql-faq-13</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/aEVaHBrhXJI/sql-faq-13.html</link><category>Security</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Wed, 26 Dec 2007 02:35:57 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-5599794571625029477</guid><description>99. What are triggers? How many triggers you can have on a table? How to invoke a trigger on  &lt;br /&gt;demand?Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table. In SQL Server 6.5 you could define only 3 triggers per table, one for INSERT, one for UPDATE and one for DELETE. From SQL Server 7.0 onwards, this restriction is gone, and you could create multiple triggers per each action. But in 7.0 there's no way to control the order in which the triggers fire. In SQL Server 2000 you could specify which trigger fires first or fires last using sp_settriggerorderTriggers can't be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined.Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster.Till SQL Server 7.0, triggers fire only after the data modification operation happens. So in a way, they are called post triggers. But in SQL Server 2000 you could create pre triggers also. Search SQL Server 2000 books online for INSTEAD OF triggers. Also check out books online for 'inserted table', 'deleted table' and COLUMNS_UPDATED()&lt;br /&gt;&lt;br /&gt;100.          There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better?&lt;br /&gt;Instantiating COM objects is a time consuming process and since you are doing it from within a trigger, it slows down the data insertion process. Same is the case with sending emails from triggers. This scenario can be better implemented by logging all the necessary data into a separate table, and have a job which periodically checks this table and does the needful.&lt;br /&gt;&lt;br /&gt;101. What is a self join? Explain it with an example.&lt;br /&gt;Self join is just like any other join, except that two instances of the same table will be joined in the query. Here is an example: Employees table which contains rows for normal employees as well as managers. So, to find out the managers of all the employees, you need a self join.CREATE TABLE emp (empid int,mgrid int,empname char(10))INSERT emp SELECT 1,2,'Vyas'INSERT emp SELECT 2,3,'Mohan'INSERT emp SELECT 3,NULL,'Shobha'INSERT emp SELECT 4,2,'Shridhar'INSERT emp SELECT 5,2,'Sourabh'SELECT t1.empname [Employee], t2.empname [Manager]FROM emp t1, emp t2WHERE t1.mgrid = t2.empid&lt;br /&gt;&lt;br /&gt;Here's an advanced query using a LEFT OUTER JOIN that even returns the employees without managers (super bosses)            SELECT t1.empname [Employee], COALESCE(t2.empname, 'No manager') [Manager]            FROM emp t1             LEFT OUTER JOIN            emp t2            ON             t1.mgrid = t2.empid&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;102.    What do you use triggers for?&lt;br /&gt;A trigger is a special type of stored procedure that is executed by the SQL Server when an Insert, Modify or Delete operation is performed Against a given table. Triggers are run AFTER the operation take effect to ensure data integrity&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;103.    What are stored procedures? Why use them? Advantages?&lt;br /&gt;Stored procedures are the way to create routines and procedures that are run on the server.&lt;br /&gt;&lt;br /&gt;Why use them?&lt;br /&gt;The execution time is much less than at the workstation&lt;br /&gt;&lt;br /&gt;Advantages:&lt;br /&gt;1. Stored procedures are compiled the first time they’re run and are stored in a system table of the current database&lt;br /&gt;2. We can execute a stored procedure on either local or remote SQL Server&lt;br /&gt;3. An application can also execute stored procedure&lt;br /&gt;&lt;br /&gt;104.    What is the difference between WHERE and HAVING clauses?&lt;br /&gt;Where clauses form a row selection expression that specifies the rows Should be included in the query.&lt;br /&gt;&lt;br /&gt;Having clauses is used to determine the groups to be displayed in the output of the SELECT statement&lt;br /&gt;&lt;br /&gt;105.    Describe the function of the "select into" statement?&lt;br /&gt;Retrieve rows and columns from one source table to a target table&lt;br /&gt;&lt;br /&gt;106. There are 100 rows in a table. How to fetch the first 10 rows from a table?&lt;br /&gt;                              SELECT TOP 10 *                               FROM [dbo].[Premium]&lt;br /&gt;                              where premium is the name of the table&lt;br /&gt;           &lt;br /&gt;107. What is the ultimate difference between SQL SERVER 7.0 and SQL SERVER 2000?&lt;br /&gt;               Speed, size, and complexity handling has improved. ODBC, connections. Basically not    &lt;br /&gt;               much different but plenty of minor differences.&lt;br /&gt;108. What is the difference between Batches and Stored Procedures?&lt;br /&gt;            Both are unrelated. Stored procedure is code preset to make alterations to the table, updating, deleting, changing items etc. the batch, is a set of records that are opened and altered in one go or by one person, the lock is placed on this batch. It is set of records and is not separate from the table, whereas stored procedure is a separate identity created for specific purpose.&lt;br /&gt;&lt;br /&gt;109. What is the GROUP BY clause. Explain with an example?&lt;br /&gt;         Groupby combines records from a column(as against sum,max,min etc).&lt;br /&gt;110. How to know description of a table in SQL server 2000?&lt;br /&gt;         sp_help &lt;object-name&gt;&lt;br /&gt;&lt;br /&gt;111. Define Heap and Extent?&lt;br /&gt;               Heap:     Heaps are collection of Datapages for a table. Each Datapage contain 8KB of &lt;br /&gt;information.&lt;br /&gt;         Extent:   A group eight (8) adjacent datapages is called Extent.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-5599794571625029477?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-26T02:35:57.080-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/sql-faq-13.html</feedburner:origLink></item><item><title>Debugging and Testing Questions-3</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/b92VPrE4TJI/debugging-and-testing-questions-3.html</link><category>Testing and Debuging</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Tue, 25 Dec 2007 01:21:04 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-3649839948729581224</guid><description>Debugging and Testing Questions&lt;br /&gt;&lt;br /&gt;49. What debugging tools come with the .NET SDK?&lt;br /&gt;1. CorDBG – command-line debugger.&lt;br /&gt;To use CorDbg, you must compile the original C# file using the /debug switch.&lt;br /&gt;2. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR.&lt;br /&gt;&lt;br /&gt;50. What does the “This” window show in the debugger?&lt;br /&gt;It points to the object that’s pointed to by this reference. Object’s instance data is shown.&lt;br /&gt;1. To do: Need a better answer.&lt;br /&gt;&lt;br /&gt;51. What does assert() method do?&lt;br /&gt;In debug compilation, assert takes in a Boolean condition as a parameter,&lt;br /&gt;and shows the error dialog if the condition is false.&lt;br /&gt;The program proceeds without any interruption if the condition is true.&lt;br /&gt;&lt;br /&gt;52. What’s the difference between the Debug class and Trace class?&lt;br /&gt;Documentation looks the same.&lt;br /&gt;Use Debug class for debug builds,&lt;br /&gt;use Trace class for both debug and release builds.&lt;br /&gt;&lt;br /&gt;53. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?&lt;br /&gt;The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;54. Where is the output of TextWriterTraceListener redirected?&lt;br /&gt;To the Console or a text file depending on the parameter passed to the constructor.&lt;br /&gt;&lt;br /&gt;55. How do you debug an ASP.NET Web application?&lt;br /&gt;Attach the aspnet_wp.exe process to the DbgClr debugger.&lt;br /&gt;&lt;br /&gt;56. What are three test cases you should go through in unit testing?&lt;br /&gt;1. Positive test cases (correct data, correct output).&lt;br /&gt;2. Negative test cases (broken or missing data, proper handling).&lt;br /&gt;3. Exception test cases (exceptions are thrown and caught properly).&lt;br /&gt;&lt;br /&gt;57. Can you change the value of a variable while debugging a C# application?&lt;br /&gt;Yes. If you are debugging via Visual Studio.NET, just go to Immediate window.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-3649839948729581224?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-25T01:21:04.648-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/debugging-and-testing-questions-3.html</feedburner:origLink></item><item><title>C# IQ-55</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/5xi89v4maN8/c-iq-55.html</link><category>C#IQ</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Tue, 25 Dec 2007 01:19:05 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-634400973781572751</guid><description>31.   What’s the implicit name of the parameter that gets passed into the set method/property of a class?&lt;br /&gt;value.  The data type of the value parameter is defined by whatever data type the property is declared as.&lt;br /&gt;&lt;br /&gt;32.   What does the keyword “virtual” declare for a method or property?&lt;br /&gt;The method or property can be overridden.&lt;br /&gt;&lt;br /&gt;33.   How is method overriding different from method overloading?&lt;br /&gt;When overriding a method, you change the behavior of the method for the derived class.  Overloading a method simply involves having another method with the same name within the class.&lt;br /&gt;&lt;br /&gt;34.   Can you declare an override method to be static if the original method is non-static?&lt;br /&gt;No.  The signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.&lt;br /&gt;&lt;br /&gt;35.   Can you override private virtual methods?&lt;br /&gt;No.  Private methods are not accessible outside the class.&lt;br /&gt;1.       Original answer:  No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.&lt;br /&gt;&lt;br /&gt;36.   What are the different ways a method can be overloaded? &lt;br /&gt;Different parameter data types, different number of parameters, different order of parameters. &lt;br /&gt;&lt;br /&gt;37.   If a base class has a number of overloaded constructors, and an inherited class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;38.   Why is it a bad idea to throw your own exceptions?&lt;br /&gt;Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block?&lt;br /&gt;Throwing your own exceptions signifies some design flaws in the project. &lt;br /&gt;39.   What’s a delegate?&lt;br /&gt;A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers. &lt;br /&gt;40.   What’s a multicast delegate?&lt;br /&gt;It’s a delegate that points to and eventually fires off several methods. &lt;br /&gt;&lt;br /&gt;41.   How is the DLL Hell problem solved in .NET?&lt;br /&gt;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. &lt;br /&gt;&lt;br /&gt;42.   What are the ways to deploy an assembly?&lt;br /&gt;An MSI installer, a CAB archive, and XCOPY command.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-634400973781572751?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-25T01:19:05.102-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/c-iq-55.html</feedburner:origLink></item><item><title>C# IQ-54</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/QQuWG2vzJMs/c-iq-54.html</link><category>C#IQ</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Tue, 25 Dec 2007 01:18:24 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-9009435340668292183</guid><description>19.   What is the role of the DataReader class in ADO.NET connections?&lt;br /&gt;It returns a read-only dataset from the data source when the command is executed.&lt;br /&gt;1.       To do: Improve the answer.&lt;br /&gt;Class Questions&lt;br /&gt;&lt;br /&gt;20.   How do you inherit from a class in C#?&lt;br /&gt;Place a colon and then the name of the base class.&lt;br /&gt;&lt;br /&gt;21.   Can you prevent your class from being inherited by another class?&lt;br /&gt;Yes.  The keyword “sealed” will prevent the class from being inherited.&lt;br /&gt;&lt;br /&gt;22.   Can you allow a class to be inherited, but prevent the method from being over-ridden?&lt;br /&gt;Yes.  Just leave the class public and make the method sealed.&lt;br /&gt;&lt;br /&gt;23.   What’s an abstract class?&lt;br /&gt;A class that cannot be instantiated.  &lt;br /&gt;An abstract class is a class that must be inherited and have the methods overridden.&lt;br /&gt;  An abstract class is essentially a blueprint for a class without any implementation.&lt;br /&gt;&lt;br /&gt;24.   When do you absolutely have to declare a class as abstract?&lt;br /&gt;1.       When at least one of the methods in the class is abstract.&lt;br /&gt;2.       When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.&lt;br /&gt;&lt;br /&gt;25.   What’s an interface class?&lt;br /&gt;It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes. &lt;br /&gt;&lt;br /&gt;26.   Why can’t you specify the accessibility modifier for methods inside the interface?&lt;br /&gt;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’s public by default.&lt;br /&gt;&lt;br /&gt;27.   Can you inherit multiple interfaces?&lt;br /&gt;Yes, why not.&lt;br /&gt;&lt;br /&gt;28.   And if they have conflicting method names?&lt;br /&gt;It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay. &lt;br /&gt;&lt;br /&gt;29.   What’s the difference between an interface and abstract class?&lt;br /&gt;In an interface class, all methods must be abstract.  In an abstract class some methods can be concrete.  In an interface class, no accessibility modifiers are allowed, which is ok in an abstract class.&lt;br /&gt;&lt;br /&gt;30.   What is the difference between a Struct and a Class?&lt;br /&gt;Structs are value-type variables and are thus saved on the stack -&gt; additional overhead but faster retrieval.  Another difference is that structs CANNOT inherit.  (questions courtesy of Eyal)&lt;br /&gt;Method and Property Questions&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-9009435340668292183?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-25T01:18:24.156-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/c-iq-54.html</feedburner:origLink></item><item><title>C# IQ-53</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/1Ho2ULgBZ-M/c-iq-53.html</link><category>C#IQ</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Tue, 25 Dec 2007 01:17:33 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-1350369023369916407</guid><description>&lt;strong&gt;C# Interview Questions&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;What is Boxing &amp;amp; UnBoxing?&lt;br /&gt;Converting a value type to reference type is called Boxing&lt;br /&gt;Unboxing is an explicit operation.&lt;br /&gt;What is hiding in CSharp ?&lt;br /&gt;Hiding is also called as Shadowing. This is the concept of Overriding the methods. It is a concept used in the Object Oriented Programming.&lt;br /&gt;What are jagged arrays in C# ?&lt;br /&gt;Multiple dimension arrays in which rows are of different length&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;C# FAQs&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;1. Does C# support multiple-inheritance?&lt;br /&gt;No, use interfaces instead.&lt;br /&gt;&lt;br /&gt;2. When you inherit a protected class-level variable, who is it available to?&lt;br /&gt;Classes in the same namespace.&lt;br /&gt;&lt;br /&gt;3. Are private class-level variables inherited?&lt;br /&gt;Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.&lt;br /&gt;&lt;br /&gt;4. Describe the accessibility modifier “protected internal”.&lt;br /&gt;It is available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).&lt;br /&gt;1. To do: Confirm the “within the same assembly” portion.&lt;br /&gt;&lt;br /&gt;5. C# provides a default class constructor for me. I decide to write a constructor that takes a string as a parameter, but want to keep the constructor that has no parameter. How many constructors should I write?&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;6. What’s the top .NET class that everything is derived from?&lt;br /&gt;System.Object.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;8. What’s the difference between System.String and System.StringBuilder classes?&lt;br /&gt;System.String is immutable.&lt;br /&gt;System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.&lt;br /&gt;&lt;br /&gt;9. What’s the advantage of using System.Text.StringBuilder over System.String?&lt;br /&gt;StringBuilder is more efficient in cases where there is a large amount of string&lt;br /&gt;manipulation. Strings are immutable, so each time it’s being operated on, a new instance is created.&lt;br /&gt;&lt;br /&gt;10. Can you store multiple data types in System.Array? No.&lt;br /&gt;&lt;br /&gt;11. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?&lt;br /&gt;The first one performs a deep copy of the array, the second one is shallow.&lt;br /&gt;&lt;br /&gt;12. How can you sort the elements of the array in descending order?&lt;br /&gt;By calling Sort() and then Reverse() methods.&lt;br /&gt;&lt;br /&gt;13. What’s the .NET class that allows the retrieval of a data element using a unique key?&lt;br /&gt;HashTable.&lt;br /&gt;&lt;br /&gt;14. What class is underneath the SortedList class?&lt;br /&gt;A sorted HashTable.&lt;br /&gt;&lt;br /&gt;15. Will the finally block get executed if an exception has not occurred?¬&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;16. What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?&lt;br /&gt;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 {}.&lt;br /&gt;1. To do: Bad question. Re-word.&lt;br /&gt;&lt;br /&gt;17. Can multiple catch blocks be executed?&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;18. Explain the three services model commonly know as a three-tier application.&lt;br /&gt;Presentation (UI), business (logic and underlying code) and data (from storage or other sources).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-1350369023369916407?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-25T01:17:33.194-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/c-iq-53.html</feedburner:origLink></item><item><title>Arrays wih examples</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/nHkmDsZgcdk/arrays-wih-examples.html</link><category>Types and Objects</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Tue, 25 Dec 2007 01:12:41 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-1804727220463055378</guid><description>&lt;strong&gt;Array types&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Arrays may be single-dimensional or multi-dimensional. Both “rectangular” and “jagged” arrays are supported.&lt;br /&gt;Single-dimensional arrays are the most common type. The example&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt;static void Main() {&lt;br /&gt;int[] arr = new int[5];&lt;br /&gt;for (int i = 0; i &lt; arr.Length; i++)&lt;br /&gt;arr[i] = i * i;&lt;br /&gt;for (int i = 0; i &lt; arr.Length; i++)&lt;br /&gt;Console.WriteLine("arr[{0}] = {1}", i, arr[i]);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;creates a single-dimensional array of int values, initializes the array elements, and then prints each of them out. The output produced is:&lt;br /&gt;arr[0] = 0&lt;br /&gt;arr[1] = 1&lt;br /&gt;arr[2] = 4&lt;br /&gt;arr[3] = 9&lt;br /&gt;arr[4] = 16&lt;br /&gt;&lt;br /&gt;The type int[] used in the previous example is an array type. Array types are written using a non-array-type followed by one or more rank specifiers. The example&lt;br /&gt;&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt;static void Main() {&lt;br /&gt;int[] a1; // single-dimensional array of int&lt;br /&gt;int[,] a2; // 2-dimensional array of int&lt;br /&gt;int[,,] a3; // 3-dimensional array of int&lt;br /&gt;int[][] j2; // "jagged" array: array of (array of int)&lt;br /&gt;int[][][] j3; // array of (array of (array of int))&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;shows a variety of local variable declarations that use array types with int as the element type.&lt;br /&gt;Array types are reference types, and so the declaration of an array variable merely sets aside space for the reference to the array. Array instances are actually created via array initializers and array creation expressions. The example&lt;br /&gt;&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt;static void Main() {&lt;br /&gt;int[] a1 = new int[] {1, 2, 3};&lt;br /&gt;int[,] a2 = new int[,] {{1, 2, 3}, {4, 5, 6}};&lt;br /&gt;int[,,] a3 = new int[10, 20, 30];&lt;br /&gt;int[][] j2 = new int[3][];&lt;br /&gt;j2[0] = new int[] {1, 2, 3};&lt;br /&gt;j2[1] = new int[] {1, 2, 3, 4, 5, 6};&lt;br /&gt;j2[2] = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9};&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;shows a variety of array creation expressions. The variables a1, a2 and a3 denote rectangular arrays, and the variable j2 denotes a jagged array. It should be no surprise that these terms are based on the shapes of the arrays. Rectangular arrays always have a rectangular shape. Given the length of each dimension of the array, its rectangular shape is clear. For example, the lengths of a3’s three dimensions are 10, 20, and 30 respectively, and it is easy to see that this array contains 10*20*30 elements.&lt;br /&gt;&lt;br /&gt;In contrast, the variable j2 denotes a “jagged” array, or an “array of arrays”. Specifically, j2 denotes an array of an array of int, or a single-dimensional array of type int[]. Each of these int[] variables can be initialized individually, and this allows the array to take on a jagged shape. The example gives each of the int[] arrays a different length. Specifically, the length of j2[0] is 3, the length of j2[1] is 6, and the length of j2[2] is 9.&lt;br /&gt;&lt;br /&gt;The element type and shape of an array—including whether it is jagged or rectangular, and the number of dimensions it has—are part of its type. On the other hand, the size of the array—as represented by the length of each of its dimensions—is not part of an array’s type. This split is made clear in the language syntax, as the length of each dimension is specified in the array creation expression rather than in the array type. For instance the declaration&lt;br /&gt;int[,,] a3 = new int[10, 20, 30];&lt;br /&gt;&lt;br /&gt;has an array type of int[,,] and an array creation expression of new int[10, 20, 30].&lt;br /&gt;For local variable and field declarations, a shorthand form is permitted so that it is not necessary to re-state the array type. For instance, the example&lt;br /&gt;&lt;br /&gt;int[] a1 = new int[] {1, 2, 3};&lt;br /&gt;can be shortened to&lt;br /&gt;int[] a1 = {1, 2, 3};&lt;br /&gt;&lt;br /&gt;without any change in program semantics.&lt;br /&gt;The context in which an array initializer such as {1, 2, 3} is used determines the type of the array being initialized. The example&lt;br /&gt;&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt;static void Main() {&lt;br /&gt;short[] a = {1, 2, 3};&lt;br /&gt;int[] b = {1, 2, 3};&lt;br /&gt;long[] c = {1, 2, 3};&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;shows that the same array initializer syntax can be used for several different array types. Because context is required to determine the type of an array initializer, it is not possible to use an array initializer in an expression context without explicitly stating the type of the array.&lt;br /&gt;Type system unification&lt;br /&gt;&lt;br /&gt;C# provides a “unified type system”. All types—including value types—derive from the type object. It is possible to call object methods on any value, even values of “primitive” types such as int. The example&lt;br /&gt;&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt;static void Main() {&lt;br /&gt;Console.WriteLine(3.ToString());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;calls the object-defined ToString method on an integer literal, resulting in the output “3”.&lt;br /&gt;The example&lt;br /&gt;&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt;static void Main() {&lt;br /&gt;int i = 123;&lt;br /&gt;object o = i; // boxing&lt;br /&gt;int j = (int) o; // unboxing&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;is more interesting. An int value can be converted to object and back again to int. This example shows both boxing and unboxing. When a variable of a value type needs to be converted to a reference type, an object box is allocated to hold the value, and the value is copied into the box. Unboxing is just the opposite. When an object box is cast back to its original value type, the value is copied out of the box and into the appropriate storage location.&lt;br /&gt;&lt;br /&gt;This type system unification provides value types with the benefits of object-ness without introducing unnecessary overhead. For programs that don’t need int values to act like objects, int values are simply 32-bit values. For programs that need int values to behave like objects, this capability is available on demand. This ability to treat value types as objects bridges the gap between value types and reference types that exists in most languages. For example, a Stack class can provide Push and Pop methods that take and return object values.&lt;br /&gt;&lt;br /&gt;public class Stack&lt;br /&gt;{&lt;br /&gt;public object Pop() {...}&lt;br /&gt;public void Push(object o) {...}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Because C# has a unified type system, the Stack class can be used with elements of any type, including value types like int&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-1804727220463055378?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-25T01:12:41.585-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/arrays-wih-examples.html</feedburner:origLink></item><item><title>types with examples</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/rwfFU-h8O5I/types-with-examples.html</link><category>Types and Objects</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Tue, 25 Dec 2007 01:10:13 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-3911753453251772390</guid><description>Types&lt;br /&gt;C# supports two kinds of types: value types and reference types. Value types include simple types (e.g., char, int, and float), enum types, and struct types. Reference types include class types, interface types, delegate types, and array types.&lt;br /&gt;Value types differ from reference types in that variables of the value types directly contain their data, whereas variables of the reference types store references to objects. With reference types, it is possible for two variables to reference the same object, and thus possible for operations on one variable to affect the object referenced by the other variable. With value types, the variables each have their own copy of the data, and it is not possible for operations on one to affect the other.&lt;br /&gt;The example&lt;br /&gt;class Class1&lt;br /&gt;{&lt;br /&gt; public int Value = 0;&lt;br /&gt;}&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt; static void Main() {&lt;br /&gt;  int val1 = 0;&lt;br /&gt;  int val2 = val1;&lt;br /&gt;  val2 = 123;&lt;br /&gt;  Class1 ref1 = new Class1();&lt;br /&gt;  Class1 ref2 = ref1;&lt;br /&gt;  ref2.Value = 123;&lt;br /&gt;  Console.WriteLine("Values: {0}, {1}", val1, val2);&lt;br /&gt;  Console.WriteLine("Refs: {0}, {1}", ref1.Value, ref2.Value);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;shows this difference. The output produced is&lt;br /&gt;Values: 0, 123&lt;br /&gt;Refs: 123, 123&lt;br /&gt;The assignment to the local variable val1 does not impact the local variable val2 because both local variables are of a value type (the type int) and each local variable of a value type has its own storage. In contrast, the assignment ref2.Value = 123; affects the object that both ref1 and ref2 reference.&lt;br /&gt;The lines&lt;br /&gt;Console.WriteLine("Values: {0}, {1}", val1, val2);&lt;br /&gt;Console.WriteLine("Refs: {0}, {1}", ref1.Value, ref2.Value);&lt;br /&gt;deserve further comment, as they demonstrate some of the string formatting behavior of Console.WriteLine, which takes a variable number of arguments. The first argument is a string, which may contain numbered placeholders like {0} and {1}. Each placeholder refers to a trailing argument with {0} referring to the second argument, {1} referring to the third argument, and so on. Before the output is sent to the console, each placeholder is replaced with the formatted value of its corresponding argument.&lt;br /&gt;Developers can define new value types through enum and struct declarations, and can define new reference types via class, interface, and delegate declarations. The example&lt;br /&gt;public enum Color&lt;br /&gt;{&lt;br /&gt; Red, Blue, Green&lt;br /&gt;}&lt;br /&gt;public struct Point &lt;br /&gt;{ &lt;br /&gt; public int x, y; &lt;br /&gt;}&lt;br /&gt;public interface IBase&lt;br /&gt;{&lt;br /&gt; void F();&lt;br /&gt;}&lt;br /&gt;public interface IDerived: IBase&lt;br /&gt;{&lt;br /&gt; void G();&lt;br /&gt;}&lt;br /&gt;public class A&lt;br /&gt;{&lt;br /&gt; protected virtual void H() {&lt;br /&gt;  Console.WriteLine("A.H");&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;public class B: A, IDerived &lt;br /&gt;{&lt;br /&gt; public void F() {&lt;br /&gt;  Console.WriteLine("B.F, implementation of IDerived.F");&lt;br /&gt; }&lt;br /&gt; public void G() {&lt;br /&gt;  Console.WriteLine("B.G, implementation of IDerived.G");&lt;br /&gt; }&lt;br /&gt; override protected void H() {&lt;br /&gt;  Console.WriteLine("B.H, override of A.H");&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;public delegate void EmptyDelegate();&lt;br /&gt;shows an example of each kind of type declaration. Later sections describe type declarations in detail.&lt;br /&gt;Predefined types&lt;br /&gt;C# provides a set of predefined types, most of which will be familiar to C and C++ developers. &lt;br /&gt;The predefined reference types are object and string. The type object is the ultimate base type of all other types. The type string is used to represent Unicode string values. Values of type string are immutable.&lt;br /&gt;The predefined value types include signed and unsigned integral types, floating point types, and the types bool, char, and decimal. The signed integral types are sbyte, short, int, and long; the unsigned integral types are byte, ushort, uint, and ulong; and the floating point types are float and double.&lt;br /&gt;The bool type is used to represent boolean values: values that are either true or false. The inclusion of bool makes it easier to write self-documenting code, and also helps eliminate the all-too-common C++ coding error in which a developer mistakenly uses “=” when “==” should have been used. In C#, the example &lt;br /&gt;int i = ...;&lt;br /&gt;F(i);&lt;br /&gt;if (i = 0)  // Bug: the test should be (i == 0)&lt;br /&gt;  G();&lt;br /&gt;results in a compile-time error because the expression i = 0 is of type int, and if statements require an expression of type bool.&lt;br /&gt;The char type is used to represent Unicode characters. A variable of type char represents a single 16-bit Unicode character.&lt;br /&gt;The decimal type is appropriate for calculations in which rounding errors caused by floating point representations are unacceptable. Common examples include financial calculations such as tax computations and currency conversions. The decimal type provides 28 significant digits.&lt;br /&gt;The table below lists the predefined types, and shows how to write literal values for each of them.&lt;br /&gt;&lt;br /&gt;Type Description Example&lt;br /&gt;object The ultimate base type of all other types object o = null;&lt;br /&gt;string String type; &lt;br /&gt;a string is a sequence of Unicode characters&lt;br /&gt; string s = "hello";&lt;br /&gt;&lt;br /&gt;sbyte 8-bit signed integral type sbyte val = 12;&lt;br /&gt;short 16-bit signed integral type short val = 12;&lt;br /&gt;int 32-bit signed integral type int val = 12;&lt;br /&gt;long 64-bit signed integral type long val1 = 12;&lt;br /&gt;long val2 = 34L;&lt;br /&gt;byte 8-bit unsigned integral type byte val1 = 12;&lt;br /&gt;ushort 16-bit unsigned integral type ushort val1 = 12;&lt;br /&gt;uint 32-bit unsigned integral type uint val1 = 12;&lt;br /&gt;uint val2 = 34U;&lt;br /&gt;ulong 64-bit unsigned integral type ulong val1 = 12;&lt;br /&gt;ulong val2 = 34U;&lt;br /&gt;ulong val3 = 56L;&lt;br /&gt;ulong val4 = 78UL;&lt;br /&gt;float Single-precision floating point type float val = 1.23F;&lt;br /&gt;double Double-precision floating point type double val1 = 1.23;&lt;br /&gt;double val2 = 4.56D;&lt;br /&gt;bool Boolean type; a bool value is either true or false bool val1 = true;&lt;br /&gt;bool val2 = false;&lt;br /&gt;char Character type; a char value is a Unicode character char val = 'h';&lt;br /&gt;decimal Precise decimal type with 28 significant digits decimal val = 1.23M;&lt;br /&gt;&lt;br /&gt;Each of the predefined types is shorthand for a system-provided type. For example, the keyword int refers to the struct System.Int32. As a matter of style, use of the keyword is favored over use of the complete system type name.&lt;br /&gt;Predefined value types such as int are treated specially in a few ways but are for the most part treated exactly like other structs. Operator overloading enables developers to define new struct types that behave much like the predefined value types. For instance, a Digit struct can support the same mathematical operations as the predefined integral types, and can define conversions between Digit and predefined types. &lt;br /&gt;The predefined types employ operator overloading themselves. For example, the comparison operators == and != have different semantics for different predefined types:&lt;br /&gt;Two expressions of type int are considered equal if they represent the same integer value. &lt;br /&gt;Two expressions of type object are considered equal if both refer to the same object, or if both are null. &lt;br /&gt;Two expressions of type string are considered equal if the string instances have identical lengths and identical characters in each character position, or if both are null.&lt;br /&gt;The example&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt; static void Main() {&lt;br /&gt;  string s = "Test";&lt;br /&gt;  string t = string.Copy(s);&lt;br /&gt;  Console.WriteLine(s == t);&lt;br /&gt;  Console.WriteLine((object)s == (object)t);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;produces the output&lt;br /&gt;True&lt;br /&gt;False&lt;br /&gt;because the first comparison compares two expressions of type string, and the second comparison compares two expressions of type object.&lt;br /&gt;Conversions&lt;br /&gt;The predefined types also have predefined conversions. For instance, conversions exist between the predefined types int and long. C# differentiates between two kinds of conversions: implicit conversions and explicit conversions. Implicit conversions are supplied for conversions that can safely be performed without careful scrutiny. For instance, the conversion from int to long is an implicit conversion. This conversion always succeeds, and never results in a loss of information. Implicit conversions can be performed implicitly, as shown in the example&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt; static void Main() {&lt;br /&gt;  int intValue = 123;&lt;br /&gt;  long longValue = intValue;&lt;br /&gt;  Console.WriteLine("{0}, {1}", intValue, longValue);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;which implicitly converts an int to a long.&lt;br /&gt;In contrast, explicit conversions are performed with a cast expression. The example&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt; static void Main() {&lt;br /&gt;  long longValue = Int64.MaxValue;&lt;br /&gt;  int intValue = (int) longValue;&lt;br /&gt;  Console.WriteLine("(int) {0} = {1}", longValue, intValue);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;uses an explicit conversion to convert a long to an int. The output is:&lt;br /&gt;(int) 9223372036854775807 = -1&lt;br /&gt;because an overflow occurs. Cast expressions permit the use of both implicit and explicit conversions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-3911753453251772390?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-25T01:10:13.376-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/types-with-examples.html</feedburner:origLink></item><item><title>faqs-05</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/nW18zbOkcbQ/faqs-05.html</link><category>NET Interoperability</category><category>Assemblies and Class</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Tue, 25 Dec 2007 00:47:52 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-6196873162580645301</guid><description>&lt;strong&gt;.NET Deployment Questions and Answers&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What do you know about .NET assemblies?&lt;br /&gt;&lt;/strong&gt;Assemblies are the smallest units of versioning and deployment in the .NET application. Assemblies are also the building blocks for programs such as Web services, Windows services, serviced components, and .NET remoting applications.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What’s the difference between private and shared assembly?&lt;/strong&gt;&lt;br /&gt;Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What’s a strong name?&lt;/strong&gt;&lt;br /&gt;A strong name includes the name of the assembly, version number, culture identity, and a public key token.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;How can you tell the application to look for assemblies at the locations other than its own install&lt;/strong&gt;?&lt;br /&gt;Use the&lt;br /&gt;directive in the XML .config file for a given application.&lt;br /&gt;&lt;br /&gt;should do the trick. Or you can add additional search paths in the Properties box of the deployed application.&lt;br /&gt;&lt;br /&gt;How can you debug failed assembly binds?&lt;br /&gt;Use the Assembly Binding Log Viewer (fuslogvw.exe) to find out the paths searched.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Where are shared assemblies stored?&lt;/strong&gt;&lt;br /&gt;Global assembly cache.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;How can you create a strong name for a .NET assembly?&lt;br /&gt;&lt;/strong&gt;With the help of Strong Name tool (sn.exe).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Where’s global assembly cache located on the system?&lt;br /&gt;&lt;/strong&gt;Usually C:\winnt\assembly or C:\windows\assembly.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Can you have two files with the same file name in GAC?&lt;br /&gt;&lt;/strong&gt;Yes, remember that GAC is a very special folder, and while normally you would not be able to place two files with the same name into a Windows folder, GAC differentiates by version number as well, so it’s possible for MyApp.dll and MyApp.dll to co-exist in GAC if the first one is version 1.0.0.0 and the second one is 1.1.0.0.&lt;br /&gt;&lt;br /&gt;So let’s say I have an application that uses MyApp.dll assembly, version 1.0.0.0. There is a security bug in that assembly, and I publish the patch, issuing it under name MyApp.dll 1.1.0.0. How do I tell the client applications that are already installed to start using this new MyApp.dll?&lt;br /&gt;&lt;br /&gt;Use publisher policy. To configure a publisher policy, use the publisher policy configuration file, which uses a format similar app .config file. But unlike the app .config file, a publisher policy file needs to be compiled into an assembly and placed in the GAC.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is delay signing?&lt;/strong&gt;&lt;br /&gt;Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development.&lt;br /&gt;.NET and COM Inteview Questions and Answers&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Describe the advantages of writing a managed code application instead of unmanaged one. What’s involved in certain piece of code being managed?&lt;br /&gt;&lt;/strong&gt;The advantages include automatic garbage collection, memory management, support for versioning and security. These advantages are provided through .NET FCL and CLR, while with the unmanaged code similar capabilities had to be implemented through third-party libraries or as a part of the application itself.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Are COM objects managed or unmanaged?&lt;/strong&gt;&lt;br /&gt;Since COM objects were written before .NET, apparently they are unmanaged.&lt;br /&gt;Any code not written in the Microsoft .NET framework environment is UNMANAGED. So naturally COM+ is unmanaged because it is written in Visual Basic 6.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;So can a COM object talk to a .NET object?&lt;br /&gt;&lt;/strong&gt;Yes, through Runtime Callable Wrapper (RCW) or PInvoke.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;How do you generate an RCW from a COM object? &lt;/strong&gt;&lt;br /&gt;Use the Type Library Import utility shipped with SDK. tlbimp COMobject.dll /out:.NETobject.dll or reference the COM library from Visual Studio in your project.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;I can’t import the COM object that I have on my machine. Did you write that object?&lt;/strong&gt;&lt;br /&gt;You can only import your own objects. If you need to use a COM component from another developer, you should obtain a Primary Interop Assembly (PIA) from whoever authored the original object.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;How do you call unmanaged methods from your .NET code through PInvoke?&lt;/strong&gt;&lt;br /&gt;Supply a DllImport attribute. Declare the methods in your .NET code as static extern. Do not implement the methods as they are implemented in your unmanaged code, you’re just providing declarations for method signatures.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Can you retrieve complex data types like structs from the PInvoke calls?&lt;/strong&gt;&lt;br /&gt;Yes, just make sure you re-declare that struct, so that managed code knows what to do with it.&lt;br /&gt;&lt;br /&gt;I &lt;strong&gt;want to expose my .NET objects to COM objects. Is that possible?&lt;/strong&gt;&lt;br /&gt;Yes, but few things should be considered first. Classes should implement interfaces explicitly. Managed types must be public. Methods, properties, fields, and events that are exposed to COM must be public. Types must have a public default constructor with no arguments to be activated from COM. Types cannot be abstract.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Can you inherit a COM class in a .NET application?&lt;/strong&gt;&lt;br /&gt;The .NET Framework extends the COM model for reusability by adding implementation inheritance. Managed types can derive directly or indirectly from a COM coclass; more specifically, they can derive from the runtime callable wrapper generated by the runtime. The derived type can expose all the method and properties of the COM object as well as methods and properties implemented in managed code. The resulting object is partly implemented in managed code and partly implemented in unmanaged code.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Suppose I call a COM object from a .NET applicaiton, but COM object throws an error. What happens on the .NET end?&lt;br /&gt;&lt;/strong&gt;COM methods report errors by returning HRESULTs; .NET methods report them by throwing exceptions. The runtime handles the transition between the two. Each exception class in the .NET Framework maps to an HRESULT.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-6196873162580645301?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-25T00:47:52.935-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/faqs-05.html</feedburner:origLink></item><item><title>serialization-12</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/Q-jXfEjEmXg/serialization-12.html</link><category>Serialization</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 13:38:55 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-5880924314113556359</guid><description>1 What is serialization?&lt;br /&gt;Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process, i.e. creating an object from a stream of bytes. Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database).&lt;br /&gt;&lt;br /&gt;2 Does the .NET Framework have in-built support for serialization?&lt;br /&gt;&lt;br /&gt;There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code.&lt;br /&gt;&lt;br /&gt;3 I want to serialize instances of my class. Should I use XmlSerializer, SoapFormatter or&lt;br /&gt;BinaryFormatter?&lt;br /&gt;&lt;br /&gt;It depends. XmlSerializer has severe limitations such as the requirement that the target class has a parameterless constructor, and only public read/write properties and fields can be serialized. However, on the plus side, XmlSerializer has good support for customising the XML document that is produced or consumed. XmlSerializer's features mean that it is most suitable for cross-platform work, or for constructing objects from existing XML documents.&lt;br /&gt;SoapFormatter and BinaryFormatter have fewer limitations than XmlSerializer. They can serialize private fields, for example. However they both require that the target class be marked with the [Serializable] attribute, so like XmlSerializer the class needs to be written with serialization in mind. Also there are some quirks to watch out for - for example on deserialization the constructor of the new object is not invoked.&lt;br /&gt;The choice between SoapFormatter and BinaryFormatter depends on the application. BinaryFormatter makes sense where both serialization and deserialization will be performed on the .NET platform and where performance is important. SoapFormatter generally makes more sense in all other cases, for ease of debugging if nothing else.&lt;br /&gt;&lt;br /&gt;4 Can I customise the serialization process?&lt;br /&gt;&lt;br /&gt;Yes. XmlSerializer supports a range of attributes that can be used to configure serialization for a particular class. For example, a field or property can be marked with the [XmlIgnore] attribute to exclude it from serialization. Another example is the [XmlElement] attribute, which can be used to specify the XML element name to be used for a particular property or field.&lt;br /&gt;Serialization via SoapFormatter/BinaryFormatter can also be controlled to some extent by attributes. For example, the [NonSerialized] attribute is the equivalent of XmlSerializer's [XmlIgnore] attribute. Ultimate control of the serialization process can be acheived by implementing the the ISerializable interface on the class whose instances are to be serialized.&lt;br /&gt;&lt;br /&gt;5 Why is XmlSerializer so slow?&lt;br /&gt;&lt;br /&gt;There is a once-per-process-per-type overhead with XmlSerializer. So the first time you serialize or deserialize an object of a given type in an application, there is a significant delay. This normally doesn't matter, but it may mean, for example, that XmlSerializer is a poor choice for loading configuration settings during startup of a GUI application.&lt;br /&gt;&lt;br /&gt;6 Why do I get errors when I try to serialize a Hashtable?&lt;br /&gt;&lt;br /&gt;XmlSerializer will refuse to serialize instances of any class that implements IDictionary, e.g. Hashtable. SoapFormatter and BinaryFormatter do not have this restriction.&lt;br /&gt;&lt;br /&gt;7 XmlSerializer is throwing a generic "There was an error reflecting MyClass" error. How do I&lt;br /&gt;find out what the problem is?&lt;br /&gt;&lt;br /&gt;Look at the InnerException property of the exception that is thrown to get a more specific error message.&lt;br /&gt;&lt;br /&gt;8 Why am I getting an InvalidOperationException when I serialize an ArrayList?&lt;br /&gt;XmlSerializer needs to know in advance what type of objects it will find in an ArrayList. To specify the type, use the XmlArrayItem attibute like this:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;public class Person&lt;br /&gt;{&lt;br /&gt;public string Name;&lt;br /&gt;public int Age;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class Population&lt;br /&gt;{&lt;br /&gt;[XmlArrayItem(typeof(Person))] public ArrayList People;&lt;br /&gt;} &lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-5880924314113556359?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T13:38:55.134-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/serialization-12.html</feedburner:origLink></item><item><title>GC-1</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/TtFy6rk_2Vo/gc-1.html</link><category>GC</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 13:35:17 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-3147333872488819174</guid><description>1 What is garbage collection?&lt;br /&gt;&lt;br /&gt;Garbage collection is a heap-management strategy where a run-time component takes responsibility for managing the lifetime of the memory used by objects. This concept is not new to .NET - Java and many other languages/runtimes have used garbage collection for some time.&lt;br /&gt;2 Is it true that objects don't always get destroyed immediately when the last reference goes away?&lt;br /&gt;&lt;br /&gt;Yes. The garbage collector offers no guarantees about the time when an object will be destroyed and its memory reclaimed.&lt;br /&gt;There was an interesting thread on the DOTNET list, started by Chris Sells, about the implications of non-deterministic destruction of objects in C#. In October 2000, Microsoft's Brian Harry posted a lengthy analysis of the problem. Chris Sells' response to Brian's posting is here.&lt;br /&gt;&lt;br /&gt;3 Why doesn't the .NET runtime offer deterministic destruction?&lt;br /&gt;&lt;br /&gt;Because of the garbage collection algorithm. The .NET garbage collector works by periodically running through a list of all the objects that are currently being referenced by an application. All the objects that it doesn't find during this search are ready to be destroyed and the memory reclaimed. The implication of this algorithm is that the runtime doesn't get notified immediately when the final reference on an object goes away - it only finds out during the next 'sweep' of the heap.&lt;br /&gt;Futhermore, this type of algorithm works best by performing the garbage collection sweep as rarely as possible. Normally heap exhaustion is the trigger for a collection sweep.&lt;br /&gt;&lt;br /&gt;4 Is the lack of deterministic destruction in .NET a problem?&lt;br /&gt;&lt;br /&gt;It's certainly an issue that affects component design. If you have objects that maintain expensive or scarce resources (e.g. database locks), you need to provide some way to tell the object to release the resource when it is done. Microsoft recommend that you provide a method called Dispose() for this purpose. However, this causes problems for distributed objects - in a distributed system who calls the Dispose() method? Some form of reference-counting or ownership-management mechanism is needed to handle distributed objects - unfortunately the runtime offers no help with this.&lt;br /&gt;&lt;br /&gt;5 Should I implement Finalize on my class? Should I implement IDisposable?&lt;br /&gt;&lt;br /&gt;This issue is a little more complex than it first appears. There are really two categories of class that require deterministic destruction - the first category manipulate unmanaged types directly, whereas the second category manipulate managed types that require deterministic destruction. An example of the first category is a class with an IntPtr member representing an OS file handle. An example of the second category is a class with a System.IO.FileStream member.&lt;br /&gt;For the first category, it makes sense to implement IDisposable and override Finalize. This allows the object user to 'do the right thing' by calling Dispose, but also provides a fallback of freeing the unmanaged resource in the Finalizer, should the calling code fail in its duty. However this logic does not apply to the second category of class, with only managed resources. In this case implementing Finalize is pointless, as managed member objects cannot be accessed in the Finalizer. This is because there is no guarantee about the ordering of Finalizer execution. So only the Dispose method should be implemented. (If you think about it, it doesn't really make sense to call Dispose on member objects from a Finalizer anyway, as the member object's Finalizer will do the required cleanup.)&lt;br /&gt;For classes that need to implement IDisposable and override Finalize, see Microsoft's documented pattern.&lt;br /&gt;Note that some developers argue that implementing a Finalizer is always a bad idea, as it hides a bug in your code (i.e. the lack of a Dispose call). A less radical approach is to implement Finalize but include a Debug.Assert at the start, thus signalling the problem in developer builds but allowing the cleanup to occur in release builds.&lt;br /&gt;&lt;br /&gt;6 Do I have any control over the garbage collection algorithm?&lt;br /&gt;&lt;br /&gt;A little. For example the System.GC class exposes a Collect method, which forces the garbage collector to collect all unreferenced objects immediately.&lt;br /&gt;Also there is a gcConcurrent setting that can be specified via the application configuration file. This specifies whether or not the garbage collector performs some of its collection activities on a separate thread. The setting only applies on multi-processor machines, and defaults to true.&lt;br /&gt;&lt;br /&gt;7 How can I find out what the garbage collector is doing?&lt;br /&gt;&lt;br /&gt;Lots of interesting statistics are exported from the .NET runtime via the '.NET CLR xxx' performance counters. Use Performance Monitor to view them.&lt;br /&gt;&lt;br /&gt;8 What is the lapsed listener problem?&lt;br /&gt;&lt;br /&gt;The lapsed listener problem is one of the primary causes of leaks in .NET applications. It occurs when a subscriber (or 'listener') signs up for a publisher's event, but fails to unsubscribe. The failure to unsubscribe means that the publisher maintains a reference to the subscriber as long as the publisher is alive. For some publishers, this may be the duration of the application.&lt;br /&gt;This situation causes two problems. The obvious problem is the leakage of the subscriber object. The other problem is the performance degredation due to the publisher sending redundant notifications to 'zombie' subscribers.&lt;br /&gt;There are at least a couple of solutions to the problem. The simplest is to make sure the subscriber is unsubscribed from the publisher, typically by adding an Unsubscribe() method to the subscriber. Another solution, documented here by Shawn Van Ness, is to change the publisher to use weak references in its subscriber list.&lt;br /&gt;&lt;br /&gt;9 When do I need to use GC.KeepAlive?&lt;br /&gt;&lt;br /&gt;It's very unintuitive, but the runtime can decide that an object is garbage much sooner than you expect. More specifically, an object can become garbage while a method is executing on the object, which is contrary to most developers' expectations. Chris Brumme explains the issue on his blog. I've taken Chris's code and expanded it into a full app that you can play with if you want to prove to yourself that this is a real problem:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#660000;"&gt;using System;&lt;br /&gt;using System.Runtime.InteropServices;&lt;br /&gt;&lt;br /&gt;class Win32&lt;br /&gt;{&lt;br /&gt;[DllImport("kernel32.dll")]&lt;br /&gt;public static extern IntPtr CreateEvent( IntPtr lpEventAttributes,&lt;br /&gt;bool bManualReset,bool bInitialState, string lpName);&lt;br /&gt;&lt;br /&gt;[DllImport("kernel32.dll", SetLastError=true)]&lt;br /&gt;public static extern bool CloseHandle(IntPtr hObject);&lt;br /&gt;&lt;br /&gt;[DllImport("kernel32.dll")]&lt;br /&gt;public static extern bool SetEvent(IntPtr hEvent);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class EventUser&lt;br /&gt;{&lt;br /&gt;public EventUser()&lt;br /&gt;{&lt;br /&gt;hEvent = Win32.CreateEvent( IntPtr.Zero, false, false, null );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;~EventUser()&lt;br /&gt;{&lt;br /&gt;Win32.CloseHandle( hEvent );&lt;br /&gt;Console.WriteLine("EventUser finalized");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void UseEvent()&lt;br /&gt;{&lt;br /&gt;UseEventInStatic( this.hEvent );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static void UseEventInStatic( IntPtr hEvent )&lt;br /&gt;{&lt;br /&gt;//GC.Collect();&lt;br /&gt;bool bSuccess = Win32.SetEvent( hEvent );&lt;br /&gt;Console.WriteLine( "SetEvent " + (bSuccess ? "succeeded" : "FAILED!") );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;IntPtr hEvent;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class App&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;EventUser eventUser = new EventUser();&lt;br /&gt;eventUser.UseEvent();&lt;br /&gt;}&lt;br /&gt;} &lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#660000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;If you run this code, it'll probably work fine, and you'll get the following output:&lt;br /&gt;SetEvent succeeded&lt;br /&gt;EventDemo finalized&lt;br /&gt;However, if you uncomment the GC.Collect() call in the UseEventInStatic() method, you'll get this output:&lt;br /&gt;EventDemo finalized&lt;br /&gt;SetEvent FAILED!&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;(Note that you need to use a release build to reproduce this problem.)&lt;br /&gt;So what's happening here? Well, at the point where UseEvent() calls UseEventInStatic(), a copy is taken of the hEvent field, and there are no further references to the EventUser object anywhere in the code. So as far as the runtime is concerned, the EventUser object is garbage and can be collected. Normally of course the collection won't happen immediately, so you'll get away with it, but sooner or later a collection will occur at the wrong time, and your app will fail.&lt;br /&gt;A solution to this problem is to add a call to GC.KeepAlive(this) to the end of the UseEvent method.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-3147333872488819174?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T13:35:17.533-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/gc-1.html</feedburner:origLink></item><item><title>.net framework introduction</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/MKZdzyLp8pQ/net-framework-introduction.html</link><category>FAQS</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 13:31:17 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-8491223854812260318</guid><description>1.1 What is .NET?&lt;br /&gt;.NET is a general-purpose software development platform, similar to Java. At its core is a virtual machine that turns intermediate language (IL) into machine code. High-level language compilers for C#, VB.NET and C++ are provided to turn source code into IL. C# is a new programming language, very similar to Java. An extensive class library is included, featuring all the functionality one might expect from a contempory development platform - windows GUI development (Windows Forms), database access (ADO.NET), web development (ASP.NET), web services, XML etc.&lt;br /&gt;&lt;br /&gt;1.2 When was .NET announced?&lt;br /&gt;Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET.&lt;br /&gt;&lt;br /&gt;1.3 What versions of .NET are there?&lt;br /&gt;The final versions of the 1.0 SDK and runtime were made publicly available around 6pm PST on 15-Jan-2002. At the same time, the final version of Visual Studio.NET was made available to MSDN subscribers.&lt;br /&gt;.NET 1.1 was released in April 2003, and was mostly bug fixes for 1.0.&lt;br /&gt;.NET 2.0 was released to MSDN subscribers in late October 2005, and was officially launched in early November.&lt;br /&gt;&lt;br /&gt;1.4 What operating systems does the .NET Framework run on?&lt;br /&gt;The runtime supports Windows Server 2003, Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on XP and Windows 2000/2003. Windows 98/ME cannot be used for development.&lt;br /&gt;IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET. However, the ASP.NET Web Matrix web server does run on XP Home.&lt;br /&gt;The .NET Compact Framework is a version of the .NET Framework for mobile devices, running Windows CE or Windows Mobile.&lt;br /&gt;The Mono project has a version of the .NET Framework that runs on Linux.&lt;br /&gt;1.5 What tools can I use to develop .NET applications?&lt;br /&gt;There are a number of tools, described here in ascending order of cost:&lt;br /&gt;• The .NET Framework SDK is free and includes command-line compilers for C++, C#, and VB.NET and various other utilities to aid development.&lt;br /&gt;• SharpDevelop is a free IDE for C# and VB.NET.&lt;br /&gt;• Microsoft Visual Studio Express editions are cut-down versions of Visual Studio, for hobbyist or novice developers.There are different versions for C#, VB, web development etc. Originally the plan was to charge $49, but MS has decided to offer them as free downloads instead, at least until November 2006. &lt;br /&gt;• Microsoft Visual Studio Standard 2005 is around $300, or $200 for the upgrade. &lt;br /&gt;• Microsoft VIsual Studio Professional 2005 is around $800, or $550 for the upgrade. &lt;br /&gt;• At the top end of the price range are the Microsoft Visual Studio Team Edition for Software Developers 2005 with MSDN Premium and Team Suite editions. &lt;br /&gt;You can see the differences between the various Visual Studio versions here. &lt;br /&gt;&lt;br /&gt;1.6 Why did they call it .NET?&lt;br /&gt;I don't know what they were thinking. They certainly weren't thinking of people using search tools. It's meaningless marketing nonsense.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-8491223854812260318?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T13:31:17.100-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/net-framework-introduction.html</feedburner:origLink></item><item><title>faqs-88</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/9uELAiEacX8/faqs-88.html</link><category>FAQS</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 13:12:30 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-8808881319232466587</guid><description>What are the new Data Controls in Asp.net 2.0?&lt;br /&gt;Data access in ASP.NET 2.0 can be accomplished completely declaratively (no code) using the new data-bound and data source controls. There are new data source controls to represent different data backends such as SQL database, business objects, and XML, and there are new data-bound controls for rendering common UI for data, such as gridview, detailsview, and formview.&lt;br /&gt;&lt;br /&gt;What are the new Navigation Controls in Asp.net 2.0?&lt;br /&gt;The navigation controls provide common UI for navigating between pages in your site, such as treeview, menu, and sitemappath. These controls use the site navigation service in ASP.NET 2.0 to retrieve the custom structure you have defined for your site.&lt;br /&gt;&lt;br /&gt;What are the new Login Controlsin Asp.net 2.0?&lt;br /&gt;The new login controls provide the building blocks to add authentication and authorization-based UI to your site, such as login forms, create user forms, password retrieval, and custom UI for logged in users or roles. These controls use the built-in membership and role services in ASP.NET 2.0 to interact with the user and role information defined for your site.&lt;br /&gt;&lt;br /&gt;What are the new Web Part Controls in Asp.net 2.0 ?&lt;br /&gt;Web parts are an exciting new family of controls that enable you to add rich, personalized content and layout to your site, as well as the ability to edit that content and layout directly from your application pages. These controls rely on the personalization services in ASP.NET 2.0 to provide a unique experience for each user in your application.&lt;br /&gt;&lt;br /&gt;What are Master Pages?&lt;br /&gt;This feature provides the ability to define common structure and interface elements for your site, such as a page header, footer, or navigation bar, in a common location called a "master page", to be shared by many pages in your site. In one simple place you can control the look, feel, and much of functionality for an entire Web site. This improves the maintainability of your site and avoids unnecessary duplication of code for shared site structure or behavior.&lt;br /&gt;&lt;br /&gt;What are Themes and Skins in 2.0, explain usgae scenario?&lt;br /&gt;The themes and skins features in ASP.NET 2.0 allow for easy customization of your site's look-and-feel. You can define style information in a common location called a "theme", and apply that style information globally to pages or controls in your site. Like Master Pages, this improves the maintainability of your site and avoid unnecessary duplication of code for shared styles.&lt;br /&gt;&lt;br /&gt;What is a profile object, why is it used?&lt;br /&gt;Using the new personalization services in ASP.NET 2.0 you can easily create customized experiences within Web applications. The Profile object enables developers to easily build strongly-typed, sticky data stores for user accounts and build highly customized, relationship based experiences. At the same time, a developer can leverage Web Parts and the personalization service to enable Web site visitors to completely control the layout and behavior of the site, with the knowledge that the site is completely customized for them. Personalizaton scenarios are now easier to build than ever before and require significantly less code and effort to implement.&lt;br /&gt;&lt;br /&gt;What is Configuration API?&lt;br /&gt;ASP.NET 2.0 contains new configuration management APIs, enabling users to programmatically build programs or scripts that create, read, and update Web.config and machine.config configuration files.&lt;br /&gt;&lt;br /&gt;What is MMC Admin Tool?&lt;br /&gt;ASP.NET 2.0 provides a new comprehensive admin tool that plugs into the existing IIS Administration MMC, enabling an administrator to graphically read or change common settings within our XML configuration files.&lt;br /&gt;&lt;br /&gt;Explain the use of Pre-compilation Tool?&lt;br /&gt;ASP.NET 2.0 delivers a new application deployment utility that enables both developers and administrators to precompile a dynamic ASP.NET application prior to deployment. This precompilation automatically identifies any compilation issues anywhere within the site, as well as enables ASP.NET applications to be deployed without any source being stored on the server (one can optionally remove the content of .aspx files as part of the compile phase), further protecting your intellectual property.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;How is application management and maintenance improved in Asp.net 2.0?&lt;br /&gt;ASP.NET 2.0 also provides new health-monitoring support to enable administrators to be automatically notified when an application on a server starts to experience problems. New tracing features will enable administrators to capture run-time and request data from a production server to better diagnose issues. ASP.NET 2.0 is delivering features that will enable developers and administrators to simplify the day-to-day management and maintenance of their Web applications.&lt;br /&gt;&lt;br /&gt;What are Provider-driven Application Services? explain in detail?&lt;br /&gt;ASP.NET 2.0 now includes built-in support for membership (user name/password credential storage) and role management services out of the box. The new personalization service enables quick storage/retrieval of user settings and preferences, facilitating rich customization with minimal code. The new site navigation system enables developers to quickly build link structures consistently across a site. As all of these services are provider-driven, they can be easily swapped out and replaced with your own custom implementation. With this extensibility option, you have complete control over the data store and schema that drives these rich application services.&lt;br /&gt;&lt;br /&gt;Explain Server Control Extensibility with reference to Asp.net 2.0 ?&lt;br /&gt;ASP.NET 2.0 includes improved support for control extensibility, such as more base classes that encapsulate common behaviors, improved designer support, more APIs for interacting with client-side script, metadata-driven support for new features like themes and accessibility verification, better state management, and more.&lt;br /&gt;&lt;br /&gt;What are the Data Source Controls?&lt;br /&gt;Data access in ASP.NET 2.0 is now performed declaratively using data source controls on a page. In this model, support for new data backend storage providers can be easily added by implementing custom data source controls. Additionally, the SqlDataSource control that ships in the box has built-in support for any ADO.NET managed provider that implements the new provider factory model in ADO.NET.&lt;br /&gt;&lt;br /&gt;What are Compilation Build Providers?&lt;br /&gt;Dynamic compilation in ASP.NET 2.0 is now handled by extensible compilation build providers, which associate a particular file extension with a handler that knows how to compile that extension dynamically at runtime. For example, .resx files can be dynamically compiled to resources, .wsdl files to web service proxies, and .xsd files to typed DataSet objects. In addition to the built-in support, it is easy to add support for additional extensions by implementing a custom build provider and registering it in Web.config.&lt;br /&gt;&lt;br /&gt;What is Expression Builders, why would you use it?&lt;br /&gt;ASP.NET 2.0 introduces a declarative new syntax for referencing code to substitute values into the page, called Expression Builders. ASP.NET 2.0 includes expression builders for referencing string resources for localization, connection strings, application settings, and profile values. You can also write your own expression builders to create your own custom syntax to substitute values in a page rendering.&lt;br /&gt;&lt;br /&gt;Is ASP.NET 64-Bit enabled? how?&lt;br /&gt;ASP.NET 2.0 is now 64-bit enabled, meaning it can take advantage of the full memory address space of new 64-bit processors and servers. Developers can simply copy existing 32-bit ASP.NET applications onto a 64-bit ASP.NET 2.0 server and have them automatically be JIT compiled and executed as native 64-bit applications (no source code changes or manual re-compile are required).&lt;br /&gt;&lt;br /&gt;Explain how Caching in Asp.net 2.0 is different from Caching in Asp.net 1.1?&lt;br /&gt;ASP.NET 2.0 also now includes automatic database server cache invalidation. This powerful and easy-to-use feature allows developers to aggressively output cache database-driven page and partial page content within a site and have ASP.NET automatically invalidate these cache entries and refresh the content whenever the back-end database changes. Developers can now safely cache time-critical content for long periods without worrying about serving visitors stale data&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-8808881319232466587?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T13:12:30.823-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/faqs-88.html</feedburner:origLink></item><item><title>NET Interoperability</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/-Ffq51LOIcY/net-interoperability.html</link><category>NET Interoperability</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 12:58:05 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-3972977770900021688</guid><description>&lt;span style="color:#003300;"&gt;&lt;em&gt;How can we use COM Components in .NET?&lt;br /&gt;&lt;br /&gt;What is RCW ?&lt;br /&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;.NET components communicate with COM using RCW (Runtime Callable Wrapper). Following&lt;br /&gt;are the ways with which you can generate RCW :-&lt;br /&gt;&lt;br /&gt;√ Adding reference in Visual Studio.net. See figure below (Adding reference using VS.NET&lt;br /&gt;    2005). Wrapper class is generated and placed in the “BIN” directory.&lt;br /&gt;&lt;br /&gt;√ Using Type library import tool. Tlbimp.exe yourname.dll.&lt;br /&gt;&lt;br /&gt;√ Using interopservices.System.runtime.Interopservices namespace contains class&lt;br /&gt;    TypeLib Converter which provides methods to convert COM classes and interface in&lt;br /&gt;    to assembly metadata.&lt;br /&gt;&lt;br /&gt;√ Make your custom wrappe rs.If your COM component does not have type library&lt;br /&gt;    then the only way to communicate is writing custom wrappers. That means&lt;br /&gt;    communicating directly with COM components.&lt;br /&gt;&lt;br /&gt;     &lt;em&gt;&lt;span style="color:#003300;"&gt;Once I have developed the COM wrapper do I have to still register the&lt;br /&gt;     COM in registry?&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;    Yes.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#003300;"&gt;How can we use .NET components in COM?&lt;br /&gt;Twist :- What is CCW (COM callable wrapper) ?&lt;br /&gt;Twist :- How do we ensure that .NET components is compatible with COM ?&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;.NET components can not be used in straight forward way with COM. You will need to create&lt;br /&gt;CCW in order that COM components communicate with .NET assemblies. Following are the&lt;br /&gt;different approaches to implement it :-&lt;br /&gt;&lt;br /&gt;√ Explicitly declare interfaces..&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#660000;"&gt;Public Interface ICustomer&lt;br /&gt;Property CustomerName() As String&lt;br /&gt;Property CustomerCode() As String&lt;br /&gt;Sub AddCustomer()&lt;br /&gt;End Interface&lt;br /&gt;Public Class Customer&lt;br /&gt;Implements ICustomer&lt;br /&gt;Private PstrCustomerName As String&lt;br /&gt;Private PstrCustomerCode As String&lt;br /&gt;Public Sub AddCustomer() Implements ICustomer.AddCustomer&lt;br /&gt;Try&lt;br /&gt;‘ addin of database code can go here&lt;br /&gt;Catch ex As Exception&lt;br /&gt;Throw ex&lt;br /&gt;End Try&lt;br /&gt;End Sub&lt;br /&gt;Public Property CustomerCode() As String Implements&lt;br /&gt;ICustomer.CustomerCode&lt;br /&gt;Get&lt;br /&gt;Return PstrCustomerCode&lt;br /&gt;End Get&lt;br /&gt;Set(ByVal value As String)&lt;br /&gt;PstrCustomerCode = value&lt;br /&gt;End Set&lt;br /&gt;End Property&lt;br /&gt;Public Property CustomerName() As String Implements&lt;br /&gt;ICustomer.CustomerName&lt;br /&gt;Get&lt;br /&gt;Return PstrCustomerName&lt;br /&gt;End Get&lt;br /&gt;Set(ByVal value As String)&lt;br /&gt;PstrCustomerName = value&lt;br /&gt;End Set&lt;br /&gt;End Property&lt;br /&gt;Public Sub New()&lt;br /&gt;End Sub&lt;br /&gt;End Class&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;           Note :- Source code of this is provided in CD in SOURCECODE folder in&lt;br /&gt;           COMCALLABLEWRAPPER&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The above customer class is going to be used by COM components so all the properties and&lt;br /&gt;methods are declared in interface and implemented in the customer class. Customer Name.Customer&lt;br /&gt;Code and AddCustomer are first declared in ICustomer and then implemented in Customer&lt;br /&gt;Class. Also note that the class must have a default constructor.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note :- All source code in this book is provided in VB.NET that does not mean that&lt;br /&gt;author of the book does not like C#. In fact the main programming language of author is&lt;br /&gt;C#. In order to keep things small I have only used one language. But the conversion is so&lt;br /&gt;seamless that it is of least matter.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;√ The second way to create CCW is by using InteropServices attributes. Here interfaces&lt;br /&gt;are created automatically.&lt;br /&gt;Following are different type of class attributes :&lt;br /&gt;None:-No class interface is generated for the class. This is default setting when you do not specify&lt;br /&gt;anything.&lt;br /&gt;AutoDispatch :- Interface that supports IDispatch is created for the class. However, no type&lt;br /&gt;information is produced.&lt;br /&gt;AutoDual :- A dual interface is created for the class. Type information is produced and made&lt;br /&gt;available in the type library.&lt;br /&gt;Below in the source code we have used the third attribute.&lt;br /&gt;&lt;em&gt;&lt;span style="color:#990000;"&gt;Imports System.Runtime.InteropServices&lt;br /&gt;&lt;classinterfaceattribute(classinterfacetype.autodual)&gt;_&lt;br /&gt;Public Class ClsCompliant&lt;br /&gt;End Class&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Other than class attributes defined up there are other attributes with which you can govern other&lt;br /&gt;part of assembly.Example “GuidAttribute” allows you to specify the GUID,&lt;br /&gt;“ComVisibleAttribute” can be used to hide .NET types from COM etc. All attributes are not in&lt;br /&gt;scope of the book as this is a interview questions book refer MSDN for more details.&lt;br /&gt;&lt;br /&gt;√ Once .NET assembly is created using either interface or using interopservices method&lt;br /&gt;   we need to create a COM type library using Type library export tool.&lt;br /&gt;   Tlbexp (AssemblyName)&lt;br /&gt;√ The final thing is registering the CCW in registry using regasm tool.&lt;br /&gt;    regasm AssemblyName [Options]&lt;br /&gt;√ Finally refer the TLB in your COM IDE Below is figure showing VB6 IDE referencing&lt;br /&gt;    the DLL&lt;br /&gt;             Note :- DLL and TLB should be in same directory where the application is executed.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;How can we make Windows API calls in .NET?&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;   Windows API call are not COM based and they are invoked through Platform Invoke Services.&lt;br /&gt;    Declare StringConversionType (Function  Sub) MethodName Lib "DllName" ([Args]) As    Type&lt;br /&gt;√ StringConversionType is for what type of conversion should take place. Either we&lt;br /&gt;    can specify Unicode to convert all strings to Unicode values, or Auto to convert&lt;br /&gt;    strings according to the .NET runtime rules.&lt;br /&gt;√ MethodName is the name of the API to call.&lt;br /&gt;√ DllName is the name of the DLL.&lt;br /&gt;√ Args are any arguments to the API call.&lt;br /&gt;√ Type is the return type of the API call.&lt;br /&gt;    Below is a sample code for VB.NET which uses Sleep windows API for delaying. &lt;br /&gt;&lt;br /&gt;    &lt;em&gt;&lt;span style="color:#003300;"&gt;Public Class Form1&lt;br /&gt;    Declare Auto Sub Sleep Lib “kernel32.dll” (ByVal dwMilliseconds As Long)&lt;br /&gt;   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As&lt;br /&gt;   System.EventArgs) Handles MyBase.Load&lt;br /&gt;   MessageBox.Show(“ start sleeping for 5000 Milli seconds.....”)&lt;br /&gt;  Sleep(5000)&lt;br /&gt;  MessageBox.Show(“ end of sleeping.....”)&lt;br /&gt;  End Sub&lt;br /&gt;  End Class&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;In VB.NET we use declare keyword but in C# it goes little bit different, we use DLLIMPORT&lt;br /&gt;here.&lt;br /&gt;&lt;br /&gt;Note :- We have interopservices in this and EXTERN keyword.&lt;br /&gt;&lt;br /&gt;#&lt;em&gt;&lt;span style="color:#660000;"&gt;region Using directives&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Drawing;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using System.Runtime.InteropServices;&lt;br /&gt;#endregion&lt;br /&gt;namespace CSharpCode&lt;br /&gt;{&lt;br /&gt;partial class Form1 : Form&lt;br /&gt;{&lt;br /&gt;[DllImport(“Kernel32.dll”)]&lt;br /&gt;static extern int Sleep(long dwMilliseconds);&lt;br /&gt;public Form1()&lt;br /&gt;{&lt;br /&gt;InitializeComponent();&lt;br /&gt;}&lt;br /&gt;private void Form1_Load(object sender, EventArgs e)&lt;br /&gt;105&lt;br /&gt;{&lt;br /&gt;MessageBox.Show(“Starting of 5000 ms...”);&lt;br /&gt;Sleep(5000);&lt;br /&gt;MessageBox.Show(“End of 5000 ms...”);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;} &lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#660000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;/span&gt;&lt;em&gt;When we use windows API in .NET is it managed or unmanaged code&lt;br /&gt;&lt;/em&gt;?&lt;br /&gt;Windows API in .NET is unmanaged code.&lt;br /&gt;Note:- Even though VB6 and V C++ has gone off still many people do ask these old&lt;br /&gt;questions again and again. Still there are decent old application which are working with&lt;br /&gt;COM very much fine. So interviewer still asks you these questions so that those&lt;br /&gt;application’s can be ported to .NET. So let’s play some old music... By the way my&lt;br /&gt;favourite music is Kishore, what’s yours???&lt;br /&gt;&lt;br /&gt;(I)What is COM ?&lt;br /&gt;&lt;br /&gt;Microsoft’s COM is a technology for component software development. It is a binary standard&lt;br /&gt;which is language independent. DCOM is a distributed extension of COM.&lt;br /&gt;&lt;br /&gt;(A) What is Reference counting in COM ?&lt;br /&gt;&lt;br /&gt;Reference counting is a memory management technique used to count how many times an object&lt;br /&gt;has a pointer referring to it. The first time it is created, the reference count is set to one. When the&lt;br /&gt;last reference to the object is nulled, the reference count is set to zero and the object is deleted.&lt;br /&gt;Care must be exercised to prevent a context switch from changing the reference count at the time&lt;br /&gt;of deletion. In the methods that follow, the syntax is shortened to keep the scope of the discussion&lt;br /&gt;brief and manageable.&lt;br /&gt;&lt;br /&gt;(A) Can you describe IUKNOWN interface in short ?&lt;br /&gt;&lt;br /&gt;Every COM object supports at least one interface, the IUnknown interface. All interfaces are&lt;br /&gt;classes derived from the base class IUnknown. Each interface supports methods access data and&lt;br /&gt;perform operations transparently to the programmer. For example, IUnknown supports three&lt;br /&gt;methods, AddRef, Release(), and QueryInterface(). Suppose that pinterf is a pointer to an IUnknown.&lt;br /&gt;pinterf-&gt;AddRef() increments the reference count. pinterf-&gt;Release() decrements the reference&lt;br /&gt;count, deleting the object when the reference count reaches zero. pinterf-&gt;QueryInterface( IDesired, pDesired) checks to see if the current interface (IUnknown) supports another interface, IDesired,&lt;br /&gt;creates an instance (via a call to CoCreateInstance()) of the object if the reference count is zero (the&lt;br /&gt;object does not yet exist), and then calls pDesired-&gt;AddRef() to increment the reference count&lt;br /&gt;(where pDesired is a pointer to IDesired) and returns the pointer to the caller.&lt;br /&gt;&lt;br /&gt;(I)Can you explain what is DCOM ?&lt;br /&gt;&lt;br /&gt;DCOM differs from COM in that it allows for creating objects distributed across a network, a&lt;br /&gt;protocol for invoking that object’s methods, and secures access to the object. DCOM provides a&lt;br /&gt;wrapper around COM, hence it is a backwards compatible extension. DCOM uses Remote&lt;br /&gt;Procedural Calls (RPC) using Open Software Foundation’s Distributed Computing Environment.&lt;br /&gt;These RPC are implemented over TCP/IP and named pipes. The protocol which is actually being&lt;br /&gt;used is registered just prior to use, as opposed to being registered at initialization time. The reason&lt;br /&gt;for this is that if a protocol is not being used, it will not be loaded.&lt;br /&gt;In order to inform an object that the client is still alive, periodic pinging is used. Hence, when the&lt;br /&gt;client has died and no ping has been received (to refresh it) before the expiration time, the server&lt;br /&gt;object will perform some clean up tasks (including decrementing its reference count).&lt;br /&gt;Since RPC across a network are typically slow (compared to processes residing on the same&lt;br /&gt;machine), DCOM sends multiple requests in the same call. For example, in COM, the program&lt;br /&gt;performs a QueryInterface, one interface at a time. In DCOM, multiple QueryInterfaces are all&lt;br /&gt;clustered into one call.&lt;br /&gt;This clustering optimization trick is also used when creating an instance of the object and serializing&lt;br /&gt;it with data. Since these two operations usually occur together, DCOM allows one method which&lt;br /&gt;will perform both operations in one call without waiting for an acknowledgment from the first&lt;br /&gt;task before performing the second one.&lt;br /&gt;Similarly, when a client pings its server object, he can do it in one call. Moreover, if there are&lt;br /&gt;multiple clients sending pings to multiple servers, an optimization is made where the multiple&lt;br /&gt;pings going to the same object are consolidated into just one ping. This is to cut down on the use&lt;br /&gt;of precious bandwidth used only for pinging.&lt;br /&gt;The client has the control to set the computer which will be responsible for the lifetime of the&lt;br /&gt;object. That is to say, these objects are not created just somewhere where the system resources and&lt;br /&gt;access privileges allow for it.&lt;br /&gt;Call security is implemented in all four ways: authentication (to prevent false clients from&lt;br /&gt;impersonating the true client), authorization (to insure that a client only does what it is authorized to do), data integrity (to insure that data was not tampered with during transit) and data privacy (to insure that only designated sources can read it). The security issues are handled as they are on operating systems. The client gives the server various access privileges to access memory or disk space&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;How do we create DCOM object in VB6? &lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;Using the CreateObject method you can create a DCOM object. You have to put the server&lt;br /&gt;name in the registry.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;How to implement DTC in .NET ? &lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;p&gt;&lt;br /&gt;&lt;/em&gt;DTC is implemented using COM+.&lt;br /&gt;Following are the steps to implement COM + in .NET :-&lt;br /&gt;√ “EnterpriseService” namespace has all the classes by which we can implement DTC&lt;br /&gt;     in .NET. You have to add reference “EnterpriseService” namespace.&lt;br /&gt;√ You class must derive from “Serviced Component” object.&lt;br /&gt;√ Then you have to define your class with the transaction attribute&lt;br /&gt;    (For all transaction attribute look the down question)&lt;br /&gt;    [ Transaction(TransactionOption.RequiresNew) ]&lt;br /&gt;√ After the class level transaction type is defined. Its time to define at the method level&lt;br /&gt;    the AutoComplete attribute. Autocomplete attribute says that if no exception is thrown&lt;br /&gt;    then mark its part of the transaction as being okay. This helps cut down on the&lt;br /&gt;    amount of code required. If the implementation sets AutoComplete to false, or &lt;br /&gt;    omits it all together, then we would need to manage the transaction manually. To&lt;br /&gt;    manually control the transaction you will need to use the ContextUtil class and its static&lt;br /&gt;    members. Following is small snippet of ContextUtil: - &lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;em&gt;&lt;span style="color:#660000;"&gt; public void SampleFunction()&lt;br /&gt;{&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;// Do something to a database&lt;br /&gt;// ...&lt;br /&gt;// Everything okay so far Commit the transaction&lt;br /&gt;ContextUtil.SetComplete();&lt;br /&gt;}&lt;br /&gt;catch(Exception)&lt;br /&gt;{&lt;br /&gt;// Something went wrong Abort and Rollback the Transaction.&lt;br /&gt;ContextUtil.SetAbort();&lt;br /&gt;}&lt;br /&gt;} &lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;em&gt;&lt;span style="color:#660000;"&gt;&lt;p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;√ Component derived from “ServicedComponent” should be strong named as they&lt;br /&gt;    run under COM+.&lt;br /&gt;√ Once the classes are compiled using the string name.Register the Component in COM+&lt;br /&gt;    services using&lt;br /&gt;    regsvcs c:\DllPath\TransactionComponent.dll&lt;br /&gt;√ You can see that the component is registered using the COM+ explorer.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;How many types of Transactions are there in COM + .NET ? &lt;/em&gt;&lt;/p&gt;&lt;em&gt;&lt;/em&gt;&lt;p&gt;&lt;br /&gt;There are 5 transactions types that can be used with COM+. Whenever an object is registered with COM+ it has to abide either to these 5 transaction types. &lt;/p&gt;&lt;p&gt;Disabled: - There is no transaction. COM+ does not provide transaction support for this&lt;br /&gt;component.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Not Supported: - Component does not support transactions. Hence even if the calling component in the hierarchy is transaction enabled this component will not participate in the transaction.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Supported: - Components with transaction type support will be a part of the transaction. This will be only if the calling component has an active transaction. If the calling component is not transaction enabled this component will not start a new transaction. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;Required: - Components with this attribute require a transaction i.e. either the calling should have a transaction in place else this component will start a new transaction. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;Required New: - Components enabled with this transaction type always require a new transaction. Components with required new transaction type instantiate a new transaction for themselves every time.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;How do you do object pooling in .NET ? &lt;/em&gt;&lt;/p&gt;&lt;em&gt;&lt;/em&gt;&lt;p&gt;&lt;br /&gt;COM+ reduces overhead by creating object from scratch. So in COM+ when object is activated&lt;br /&gt;its activated from pool and when its deactivated it’s pushed back to the pool. Object pooling is&lt;br /&gt;configures by using the “ObjectPoolingAttribute” to the class. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;Note:- When a class is marked with objectpooling attribute it can not be inherited.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;span style="color:#660000;"&gt;ObjectPooling(MinPoolSize := 2, MaxPoolSize := 5, CreationTimeout := 20000)&gt; _&lt;br /&gt;Public Class testingclass&lt;br /&gt;Inherits ServicedComponent&lt;br /&gt;Public Sub DoWork()&lt;br /&gt;' Method contents go here.&lt;br /&gt;End Sub&lt;br /&gt;End Class &lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Above is a sample code which has the “ObjectPooling” attribute defined. Below is a sample code&lt;br /&gt;which uses the class. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#660000;"&gt;Public Class App&lt;br /&gt;Overloads Public Shared Sub Main(args() As String)&lt;br /&gt;Dim xyz As New TestObjectPooling()&lt;br /&gt;xyz.doWork()&lt;br /&gt;ServicedComponent.DisposeObject (xyz)&lt;br /&gt;End Sub&lt;br /&gt;End Class &lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Above is a sample code which uses the object pooled object. Note the DisposeObject() This&lt;br /&gt;ensures its safe return to the object pool. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt; What are types of compatibility in VB6? &lt;/em&gt;&lt;/p&gt;&lt;em&gt;&lt;p&gt;&lt;br /&gt;&lt;/em&gt;There are three possible project compatibility settings:&lt;br /&gt;√ No Compatibility&lt;br /&gt;√ Project Compatibility&lt;br /&gt;√ Binary Compatibility &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;No Compatibility&lt;br /&gt;&lt;/strong&gt;With this setting, new class ID’s, new interface ID’s and a new type library ID will be generated by&lt;br /&gt;VB each time the ActiveX component project is compiled. This will cause any compiled client&lt;br /&gt;components to fail (with error 429!) and report a missing reference to the 'VB ActiveX Test&lt;br /&gt;Component' when a client project is loaded in the VB IDE. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;Note :- Use this setting to compile the initial release of a component to other developers. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Project Compatibility&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;With this setting, VB will generate new interface ID’s for classes whose interfaces have changed,&lt;br /&gt;but will not change the class ID’s or the type library ID. This will still cause any compiled client&lt;br /&gt;components to fail (with error 429!) but will not report a missing reference to the 'VB ActiveX&lt;br /&gt;Test Component' when a client project is loaded in the VB IDE. Recompilation of client&lt;br /&gt;components will restore them to working order again.&lt;br /&gt;Note:- Use this setting during the initial development and testing of a component within&lt;br /&gt;the IDE and before the component is released to other developers.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;strong&gt;Binary Compatibility&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;VB makes it possible to extend an existing class or interface by adding new methods and properties&lt;br /&gt;etc. and yet still retain binary compatibility. It can do this, because it silently creates a new interface&lt;br /&gt;ID for the extended interface and adds registration code to register the original interface ID but&lt;br /&gt;with a new Forward key containing the value of this new interface ID. COM will then substitute&lt;br /&gt;calls having the old ID with the new ID and hence applications built against the old interface will&lt;br /&gt;continue to work (assuming the inner workings of the component remain backward compatible!).&lt;br /&gt;With this setting, VB will not change any of the existing class, interface or type library ID’s, however&lt;br /&gt;in order that it can do so, VB requires the project to specify an existing compiled version that it can&lt;br /&gt;compare against to ensure that existing interfaces have not been broken &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;What is equivalent for regsvr32 exe in .NET ?&lt;/em&gt;&lt;br /&gt;Regasm&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-3972977770900021688?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T12:58:05.519-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/net-interoperability.html</feedburner:origLink></item><item><title>difference ASP.NET Web Services and .NET Remoting</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/7AJH3jzWex8/difference-aspnet-web-services-and-net.html</link><category>Remoting</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 12:26:19 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-4432286729702158041</guid><description>&lt;em&gt;&lt;span style="color:#330033;"&gt;ASP.NET Web Services and .NET Remoting&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;1.&lt;em&gt;Protocol&lt;/em&gt;&lt;/span&gt; &lt;br /&gt;&lt;span&gt;&lt;/span&gt;&lt;br /&gt;Can be accessed only over HTTP&lt;br /&gt;Can be accessed over any protocol (including TCP, HTTP, SMTP and so on)&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#000099;"&gt;2.State Management&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Web services work in a stateless environment&lt;br /&gt;Provide support for both stateful and stateless environments through Singleton and SingleCall objects&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#000099;"&gt;3.&lt;/span&gt;&lt;span style="color:#000099;"&gt;Type System&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Web services support only the datatypes defined in the XSD type system, limiting the number of objects that can be serialized.&lt;br /&gt;Using binary communication, .NET Remoting can provide support for rich type system&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#000099;"&gt;4&lt;/span&gt;&lt;span style="color:#000099;"&gt;.Interoperability&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Web services support interoperability across platforms, and are ideal for heterogeneous environments.&lt;br /&gt;.NET remoting requires the client be built using .NET, enforcing homogenous environment.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;&lt;em&gt;5.Reliability&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Highly reliable due to the fact that Web services are always hosted in IIS&lt;br /&gt;Can also take advantage of IIS for fault isolation. If IIS is not used, application needs to provide plumbing for ensuring the reliability of the application.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#000099;"&gt;6.Extensibility&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Provides extensibility by allowing us to intercept the SOAP messages during the serialization and deserialization stages.&lt;br /&gt;Very extensible by allowing us to customize the different components of the .NET remoting framework.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#000099;"&gt;7.Ease-of-Programming&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Easy-to-create and deploy.&lt;br /&gt;Complex to program.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-4432286729702158041?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T12:26:19.288-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/difference-aspnet-web-services-and-net.html</feedburner:origLink></item><item><title>Security</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/j-RlUA1OpWU/security.html</link><category>Security</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 12:08:16 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-5472366386770017893</guid><description>What is Code Access security? What is CAS in .NET?&lt;br /&gt;Ans. CAS is the feature of the .NET security model that determines whether an application or a piece of code is permitted to run and decide the resources it can use while running&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-5472366386770017893?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T12:08:16.553-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/security.html</feedburner:origLink></item><item><title>oops-9</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/FifdRnOeg-8/oops-9.html</link><category>OOPS</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 12:07:34 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-538614781113825596</guid><description>Q41. How to instruct the garbage collector to collect unreferenced data?&lt;br /&gt;Ans. We may call the garbage collector to collect unreferenced data by executing the System.GC.Collect() method. &lt;br /&gt;&lt;br /&gt;Q42. How can we set the Focus on a control in ASP.NET?&lt;br /&gt;Ans. txtBox123.Focus(); OR Page.SetFocus(NameOfControl); &lt;br /&gt;&lt;br /&gt;Q43. What are Partial Classes in Asp.Net 2.0?&lt;br /&gt;Ans. In .NET 2.0, a class definition may be split into multiple physical files but partial classes do not make any difference to the compiler as during compile time, the compiler groups all the partial classes and treats them as a single class. &lt;br /&gt;&lt;br /&gt;Q44. How to set the default button on a Web Form? &lt;br /&gt;Ans. &lt;asp:form id="form1" runat="server" defaultbutton="btnGo"/&gt;&lt;br /&gt;&lt;br /&gt;Q45.Can we force the garbage collector to run?&lt;br /&gt;Ans. Yes, using the System.GC.Collect(), the garbage collector is forced to run in case required to do so. &lt;br /&gt;&lt;br /&gt;Q46. What is Boxing and Unboxing?&lt;br /&gt;Ans. Boxing is the process where any value type can be implicitly converted to a reference type object while Unboxing is the opposite of boxing process where the reference type is converted to a value type.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-538614781113825596?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T12:07:34.272-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/oops-9.html</feedburner:origLink></item><item><title>Remoting-3</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/yFAM0A_v7qE/remoting-3.html</link><category>Remoting</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 12:06:21 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-3858660865871540582</guid><description>Q48. What is Multi-tasking?&lt;br /&gt;Ans. It is a feature of operating systems through which multiple programs may run on the operating system at the same time, just like a scenario where a Notepad, a Calculator and the Control Panel are open at the same time. &lt;br /&gt;&lt;br /&gt;Q49. What is Multi-threading?&lt;br /&gt;Ans. When an application performs different tasks at the same time, the application is said to exhibit multithreading as several threads of a process are running.2 &lt;br /&gt;&lt;br /&gt;Q50. What is a Thread?&lt;br /&gt;Ans. A thread is an activity started by a process and its the basic unit to which an operating system allocates processor resources. &lt;br /&gt;&lt;br /&gt;Q51. What does AddressOf in VB.NET operator do?&lt;br /&gt;Ans. The AddressOf operator is used in VB.NET to create a delegate object to a method in order to point to it. &lt;br /&gt;&lt;br /&gt;Q52. How to refer to the current thread of a method in .NET?&lt;br /&gt;Ans. In order to refer to the current thread in .NET, the Thread.CurrentThread method can be used. It is a public static property. &lt;br /&gt;&lt;br /&gt;Q53. How to pause the execution of a thread in .NET?&lt;br /&gt;Ans. The thread execution can be paused by invoking the Thread.Sleep(IntegerValue) method where IntegerValue is an integer that determines the milliseconds time frame for which the thread in context has to sleep. &lt;br /&gt;&lt;br /&gt;Q54. How can we force a thread to sleep for an infinite period?&lt;br /&gt;Ans. Call the Thread.Interupt() method. &lt;br /&gt;&lt;br /&gt;Q55. What is Suspend and Resume in .NET Threading?&lt;br /&gt;Ans. Just like a song may be paused and played using a music player, a thread may be paused using Thread.Suspend method and may be started again using the Thread.Resume method. Note that sleep method immediately forces the thread to sleep whereas the suspend method waits for the thread to be in a persistable position before pausing its activity. &lt;br /&gt;&lt;br /&gt;Q56. How can we prevent a deadlock in .Net threading?&lt;br /&gt;Ans. Using methods like Monitoring, Interlocked classes, Wait handles, Event raising from between threads, using the ThreadState property.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-3858660865871540582?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T12:06:21.782-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/remoting-3.html</feedburner:origLink></item><item><title>oops</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/N_kyW7ksrW4/oops.html</link><category>OOPS</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 12:04:53 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-1888008876141756572</guid><description>Q21. What is encapsulation?&lt;br /&gt;Ans. Encapsulation is the OOPs concept of binding the attributes and behaviors in a class, hiding the implementation of the class and exposing the functionality. &lt;br /&gt;&lt;br /&gt;Q22. What is Overloading?&lt;br /&gt;Ans. When we add a new method with the same name in a same/derived class but with different number/types of parameters, the concept is called overluoad and this ultimately implements Polymorphism. &lt;br /&gt;&lt;br /&gt;Q23. What is Overriding?&lt;br /&gt;Ans. When we need to provide different implementation in a child class than the one provided by base class, we define the same method with same signatures in the child class and this is called overriding. &lt;br /&gt;&lt;br /&gt;Q24. What is a Delegate? &lt;br /&gt;Ans. A delegate is a strongly typed function pointer object that encapsulates a reference to a method, and so the function that needs to be invoked may be called at runtime. &lt;br /&gt;&lt;br /&gt;Q25. Is String a Reference Type or Value Type in .NET? &lt;br /&gt;Ans. String is a Reference Type object. &lt;br /&gt;&lt;br /&gt;Q26. What is a Satellite Assembly? &lt;br /&gt;Ans. Satellite assemblies contain resource files corresponding to a locale (Culture + Language) and these assemblies are used in deploying an application globally for different languages. &lt;br /&gt;&lt;br /&gt;Q27. What are the different types of assemblies and what is their use?&lt;br /&gt;Ans. Private, Public(also called shared) and Satellite Assemblies. &lt;br /&gt;&lt;br /&gt;Q28. Are MSIL and CIL the same thing?&lt;br /&gt;Ans. Yes, CIL is the new name for MSIL. &lt;br /&gt;&lt;br /&gt;Q29. What is the base class of all web forms?&lt;br /&gt;Ans. System.Web.UI.Page &lt;br /&gt;&lt;br /&gt;Q30. How to add a client side event to a server control?&lt;br /&gt;Ans. Example... BtnSubmit.Attributes.Add("onclick","javascript:fnSomeFunctionInJavascript()"); &lt;br /&gt;&lt;br /&gt;Q31. How to register a client side script from code-behind?&lt;br /&gt;Ans. Use the Page.RegisterClientScriptBlock method in the server side code to register the script that may be built using a StringBuilder. &lt;br /&gt;&lt;br /&gt;Q32. Can a single .NET DLL contain multiple classes?&lt;br /&gt;Ans. Yes, a single .NET DLL may contain any number of classes within it. &lt;br /&gt;&lt;br /&gt;Q33. What is DLL Hell?&lt;br /&gt;Ans. DLL Hell is the name given to the problem of old unmanaged DLL's due to which there was a possibility of version conflict among the DLLs. &lt;br /&gt;&lt;br /&gt;Q34. can we put a break statement in a finally block?&lt;br /&gt;Ans. The finally block cannot have the break, continue, return and goto statements. &lt;br /&gt;&lt;br /&gt;Q35. What is a CompositeControl in .NET?&lt;br /&gt;Ans. CompositeControl is an abstract class in .NET that is inherited by those web controls that contain child controls within them. &lt;br /&gt;&lt;br /&gt;Q36. Which control in asp.net is used to display data from an xml file and then displayed using XSLT?&lt;br /&gt;Ans. Use the asp:Xml control and set its DocumentSource property for associating an xml file, and set its TransformSource property to set the xml control's xsl file for the XSLT transformation. &lt;br /&gt;&lt;br /&gt;Q37. Can we run ASP.NET 1.1 application and ASP.NET 2.0 application on the same computer?&lt;br /&gt;Ans. Yes, though changes in the IIS in the properties for the site have to be made during deployment of each. &lt;br /&gt;&lt;br /&gt;Q38. What are the new features in .NET 2.0? &lt;br /&gt;Ans. Plenty of new controls, Generics, anonymous methods, partial classes, iterators, property visibility (separate visibility for get and set) and static classes. &lt;br /&gt;&lt;br /&gt;Q39. Can we pop a MessageBox in a web application?&lt;br /&gt;Ans. Yes, though this is done clientside using an alert, prompt or confirm or by opening a new web page that looks like a messagebox. &lt;br /&gt;&lt;br /&gt;Q40. What is managed data?&lt;br /&gt;Ans. The data for which the memory management is taken care by .Net runtime’s garbage collector, and this includes tasks for allocation de-allocation&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-1888008876141756572?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T12:04:53.688-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/oops.html</feedburner:origLink></item><item><title>Types,namespaces,GC</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/f4oxSJ2TusM/typesnamespacesgc.html</link><category>Types and Objects</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 10:45:00 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-8088810197551172902</guid><description>1. What’s the implicit name and type of the parameter that gets passed into the class’ set method?&lt;br /&gt;&lt;br /&gt;Value, and it’s data type depends on whatever variable we’re changing.&lt;br /&gt;&lt;br /&gt;2. How do you inherit from a class in C#?&lt;br /&gt;&lt;br /&gt;Place a colon and then the name of the base class. Notice that it’s double colon in C++.&lt;br /&gt;&lt;br /&gt;3. Does C# support multiple inheritance?&lt;br /&gt;&lt;br /&gt;No, use interfaces instead.&lt;br /&gt;&lt;br /&gt;4. When you inherit a protected class-level variable, who is it available to?&lt;br /&gt;&lt;br /&gt;Classes in the same namespace.&lt;br /&gt;&lt;br /&gt;5. Are private class-level variables inherited?&lt;br /&gt;&lt;br /&gt;Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.&lt;br /&gt;&lt;br /&gt;6. Describe the accessibility modifier protected internal. It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).&lt;br /&gt;&lt;br /&gt;7. C# provides a default constructor for me. I write a constructor that akes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;8. What’s the top .NET class that everything is derived from? System.Object .&lt;br /&gt;&lt;br /&gt;9. How’s method overriding different from overloading?&lt;br /&gt;&lt;br /&gt;When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.&lt;br /&gt;&lt;br /&gt;10. What does the keyword virtual mean in the method definition? The method can be over-ridden.&lt;br /&gt;&lt;br /&gt;11. Can you declare the override method static while the original method is non-static?&lt;br /&gt;&lt;br /&gt;No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.&lt;br /&gt;&lt;br /&gt;12. Can you override private virtual methods?&lt;br /&gt;&lt;br /&gt;No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.&lt;br /&gt;&lt;br /&gt;13. Can you prevent your class from being inherited and becoming a base class for some other classes?&lt;br /&gt;&lt;br /&gt;Yes, that’s 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’s the same concept as final class in Java.&lt;br /&gt;&lt;br /&gt;14. Can you allow class to be inherited, but prevent the method from being over-ridden?&lt;br /&gt;&lt;br /&gt;Yes, just leave the class public and make the method sealed.&lt;br /&gt;&lt;br /&gt;15. What’s an abstract class?&lt;br /&gt;&lt;br /&gt;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’s a blueprint for a class without any implementation.&lt;br /&gt;&lt;br /&gt;16. When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;17. What’s an interface class? It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.&lt;br /&gt;&lt;br /&gt;18. Why can’t you specify the accessibility modifier for methods inside the interface?&lt;br /&gt;&lt;br /&gt;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’s public by default.&lt;br /&gt;&lt;br /&gt;19. Can you inherit multiple interfaces?&lt;br /&gt;Yes, why not.&lt;br /&gt;&lt;br /&gt;20. And if they have conflicting method names?&lt;br /&gt;&lt;br /&gt; It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.&lt;br /&gt;&lt;br /&gt;21. What’s the difference between an interface and abstract class?&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;22. How can you overload a method?&lt;br /&gt;&lt;br /&gt;Different parameter data types, different number of parameters, different order of parameters.&lt;br /&gt;&lt;br /&gt;23. 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?&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;24. What’s the difference between System. String and System.StringBuilder classes?&lt;br /&gt;&lt;br /&gt;System. String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed&lt;br /&gt;&lt;br /&gt;25. How big is the data type int in .NET?&lt;br /&gt;&lt;br /&gt;32 bits.&lt;br /&gt;&lt;br /&gt;26. How big is the char?&lt;br /&gt;&lt;br /&gt;16 bits (Unicode).&lt;br /&gt;&lt;br /&gt;27. How do you initiate a string without escaping each backslash? Put an @ sign in front of the double-quoted string.&lt;br /&gt;&lt;br /&gt;28. What are valid signatures for the Main function? public static void Main () public static int Main () public static void Main ( string[] args ) public static int Main (string[] args )&lt;br /&gt;&lt;br /&gt;29. How do you initialize a two-dimensional array that you don’t know the dimensions of? int [ , ] myArray; //declaration myArray = new int [5, 8]; //actual initialization&lt;br /&gt;&lt;br /&gt;30. What’s the access level of the visibility type internal? Current application.&lt;br /&gt;&lt;br /&gt;31. What’s the difference between struct and class in C#? Structs cannot be inherited. Structs are passed by value, not by reference. Struct is stored on the stack, not the heap.&lt;br /&gt;&lt;br /&gt; 32. Explain encapsulation. The implementation is hidden, the interface is exposed.&lt;br /&gt;&lt;br /&gt;33. What data type should you use if you want an 8-bit value that’s signed? sbyte .&lt;br /&gt;&lt;br /&gt;34. Speaking of Boolean data types, what’s different between C# and /C++? There’s no conversion between 0 and false, as well as any other number and true, like in C/C++.&lt;br /&gt;&lt;br /&gt;35. Where are the value-type variables allocated in the computer RAM? Stack.&lt;br /&gt;&lt;br /&gt;36. Where do the reference-type variables go in the RAM? The references go on the stack, while the objects themselves go on the heap.&lt;br /&gt;&lt;br /&gt;37. What is the difference between the value-type variables and reference-type variables in terms of garbage collection? The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null.&lt;br /&gt;&lt;br /&gt;38How do you convert a string into an integer in .NET? Int32.Parse( string)&lt;br /&gt;&lt;br /&gt;39How do you box a primitive data type variable? Assign it to the object, pass an object.&lt;br /&gt;&lt;br /&gt;40Why do you need to box a primitive variable?&lt;br /&gt;&lt;br /&gt;To pass it by reference.&lt;br /&gt;&lt;br /&gt;41What’s the difference between Java and .NET garbage collectors?&lt;br /&gt;&lt;br /&gt;Sun left the implementation of a specific garbage collector up to the JRE developer, so their performance varies widely, depending on whose JRE you’re using. Microsoft standardized on their garbage collection.&lt;br /&gt;&lt;br /&gt;42How do you enforce garbage collection in .NET? System.GC.Collect ( );&lt;br /&gt;&lt;br /&gt;43.an you declare a C++ type destructor in C# like ~MyClass ()?&lt;br /&gt;&lt;br /&gt;Yes, but what’s the point, since it will call Finalize(), and Finalize() has no guarantees when the memory will be cleaned up, plus, it introduces additional load on the garbage collector.&lt;br /&gt;&lt;br /&gt;44What’s different about namespace declaration when comparing that to package declaration in Java?&lt;br /&gt; No semicolon.&lt;br /&gt;&lt;br /&gt; 45What’s the difference between const and read only?&lt;br /&gt;&lt;br /&gt;You can initialize read only variables to some runtime values. Let’s say your program uses current date and time as one of the values that won’t change. This way you declare public read only string DateT = new DateTime ().ToString ().&lt;br /&gt;&lt;br /&gt; 46\a character do?&lt;br /&gt;On most systems, produces a rather annoying beep.&lt;br /&gt;&lt;br /&gt;47. Can you create enumerated data types in C#?&lt;br /&gt; Yes.&lt;br /&gt;&lt;br /&gt;48. What’s different about switch statements in C#?&lt;br /&gt;&lt;br /&gt;No fall-throughs allowed.&lt;br /&gt;&lt;br /&gt;49. What happens when you encounter a continue statement inside the for loop?&lt;br /&gt;&lt;br /&gt;The code for the rest of the loop is ignored; the control is transferred back to the beginning of the loop.&lt;br /&gt;&lt;br /&gt;50. Is goto statement supported in C#? How about Java?&lt;br /&gt;&lt;br /&gt;Gotos are supported in C# to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-8088810197551172902?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T10:45:00.670-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/typesnamespacesgc.html</feedburner:origLink></item><item><title>.net framework</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/-mkhP1mK0cY/net-framework.html</link><category>Assemblies and  Class</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 10:30:54 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-1890918230945016465</guid><description>40. What is an assembly?&lt;br /&gt;Assembly is a deployment unit of .NET application. In practical terms assembly is an Executable or a class library.&lt;br /&gt;&lt;br /&gt;41. What is CLR?&lt;br /&gt;The common language runtime is the execution engine for .NET Framework applications. It provides a number of services, including the following: • Code management (loading and execution) Application memory isolation • Verification of type safety • Conversion of IL to native code • Access to metadata (enhanced type information) • Managing memory for managed objects • Enforcement of code access security • Exception handling, including cross-language exceptions • Interoperation between managed code, COM objects, and pre-existing DLLs (unmanaged code and data) • Automation of object layout • Support for developer services (profiling, debugging, and so on)&lt;br /&gt;&lt;br /&gt;42. What is the common type system (CTS)?&lt;br /&gt;The common type system is a rich type system, built into the common language runtime that supports the types and operations found in most programming languages. The common type system supports the complete implementation of a wide range of programming languages.&lt;br /&gt;&lt;br /&gt; 43. What is the Common Language Specification (CLS)?&lt;br /&gt;The Common Language Specification is a set of constructs and constraints that serves as a guide for library writers and compiler writers. It allows libraries to be fully usable from any language supporting the CLS, and for those languages to integrate with each other. The Common Language Specification is a subset of the common type system. The Common Language Specification is also important to application developers who are writing code that will be used by other developers. When developers design publicly accessible APIs following the rules of the CLS, those APIs are easily used from all other programming languages that target the common language runtime.&lt;br /&gt;&lt;br /&gt;44. What is the Microsoft Intermediate Language (MSIL)?&lt;br /&gt;MSIL is the CPU-independent instruction set into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects. Combined with metadata and the common type system, MSIL allows for true cross-language integration. Prior to execution, MSIL is converted to machine code. It is not interpreted.&lt;br /&gt;&lt;br /&gt;45. What is managed code and managed data?&lt;br /&gt;Managed code is code that is written to target the services of the common language runtime (see what is the Common Language Runtime?). In order to target these services, the code must provide a minimum level of information (metadata) to the runtime. All C#, Visual Basic .NET, and JScript .NET code is managed by default. Visual Studio .NET C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/CLR). Closely related to managed code is managed data—data that is allocated and de-allocated by the common language runtime's garbage collector. C#, Visual Basic, and JScript .NET data is managed by default. C# data can, however, be marked as unmanaged through the use of special keywords. Visual Studio .NET C++ data is unmanaged by default (even when using the /CLR switch), but when using Managed Extensions for C++, a class can be marked as managed by using the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector. In addition, the class becomes a full participating member of the .NET Framework community, with the benefits and restrictions that brings. An example of a benefit is proper interoperability with classes written in other languages (for example, a managed C++ class can inherit from a Visual Basic class). An example of a restriction is that a managed class can only inherit from one base class.&lt;br /&gt;&lt;br /&gt;46. What is an assembly?&lt;br /&gt;An assembly is the primary building block of a .NET Framework application. It is a collection of functionality that is built, versioned, and deployed as a single implementation unit (as one or more files). All managed types and resources are marked either as accessible only within their implementation unit or as accessible by code outside that unit. Assemblies are self-describing by means of their manifest, which is an integral part of every assembly. The manifest: Establishes the assembly identity (in the form of a text name), version, culture, and digital signature (if the assembly is to be shared across applications). Defines what files (by name and file hash) make up the assembly implementation. Specifies the types and resources that make up the assembly, including which are exported from the assembly. Itemizes the compile-time dependencies on other assemblies. Specifies the set of permissions required for the assembly to run properly. This information is used at run time to resolve references, enforce version binding policy, and validate the integrity of loaded assemblies. The runtime can determine and locate the assembly for any running object, since every type is loaded in the context of an assembly. Assemblies are also the unit at which code access security permissions are applied. The identity evidence for each assembly is considered separately when determining what permissions to grant the code it contains. The self-describing nature of assemblies also helps makes zero-impact install and XCOPY deployment feasible.&lt;br /&gt;&lt;br /&gt; 47. What are private assemblies and shared assemblies?&lt;br /&gt; A private assembly is used only by a single application, and is stored in that application's install directory (or a subdirectory therein). A shared assembly is one that can be referenced by more than one application. In order to share an assembly, the assembly must be explicitly built for this purpose by giving it a cryptographically strong name (referred to as a strong name). By contrast, a private assembly name need only be unique within the application that uses it. By making a distinction between private and shared assemblies, we introduce the notion of sharing as an explicit decision. Simply by deploying private assemblies to an application directory, you can guarantee that that application will run only with the bits it was built and deployed with. References to private assemblies will only be resolved locally to the private application directory. There are several reasons you may elect to build and use shared assemblies, such as the ability to express version policy. The fact that shared assemblies have a cryptographically strong name means that only the author of the assembly has the key to produce a new version of that assembly. Thus, if you make a policy statement that says you want to accept a new version of an assembly, you can have some confidence that version updates will be controlled and verified by the author. Otherwise, you don't have to accept them. For locally installed applications, a shared assembly is typically explicitly installed into the global assembly cache (a local cache of assemblies maintained by the .NET Framework). Key to the version management features of the .NET Framework is that downloaded code does not affect the execution of locally installed applications. Downloaded code is put in a special download cache and is not globally available on the machine even if some of the downloaded components are built as shared assemblies. The classes that ship with the .NET Framework are all built as shared assemblies.&lt;br /&gt;&lt;br /&gt;48. If I want to build a shared assembly, does that require the overhead of signing and managing key pairs?&lt;br /&gt;Building a shared assembly does involve working with cryptographic keys. Only the public key is strictly needed when the assembly is being built. Compilers targeting the .NET Framework provide command line options (or use custom attributes) for supplying the public key when building the assembly. It is common to keep a copy of a common public key in a source database and point build scripts to this key. Before the assembly is shipped, the assembly must be fully signed with the corresponding private key. This is done using an SDK tool called SN.exe (Strong Name). Strong name signing does not involve certificates like Authenticode does. There are no third party organizations involved, no fees to pay, and no certificate chains. In addition, the overhead for verifying a strong name is much less than it is for Authenticode. However, strong names do not make any statements about trusting a particular publisher. Strong names allow you to ensure that the contents of a given assembly haven't been tampered with, and that the assembly loaded on your behalf at run time comes from the same publisher as the one you developed against. But it makes no statement about whether you can trust the identity of that publisher.&lt;br /&gt;&lt;br /&gt; 49. What is the difference between a namespace and an assembly name?&lt;br /&gt;A namespace is a logical naming scheme for types in which a simple type name, such as MyType, is preceded with a dot-separated hierarchical name. Such a naming scheme is completely under the control of the developer. For example, types MyCompany.FileAccess.A and MyCompany.FileAccess.B might be logically expected to have functionality related to file access. The .NET Framework uses a hierarchical naming scheme for grouping types into logical categories of related functionality, such as the Microsoft® ASP.NET application framework, or remoting functionality. Design tools can make use of namespaces to make it easier for developers to browse and reference types in their code. The concept of a namespace is not related to that of an assembly. A single assembly may contain types whose hierarchical names have different namespace roots, and a logical namespace root may span multiple assemblies. In the .NET Framework, a namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.&lt;br /&gt;&lt;br /&gt;50. What options are available to deploy my .NET applications?&lt;br /&gt;&lt;br /&gt;The .NET Framework simplifies deployment by making zero-impact install and XCOPY deployment of applications feasible. Because all requests are resolved first to the private application directory, simply copying an application's directory files to disk is all that is needed to run the application. No registration is required. This scenario is particularly compelling for Web applications, Web Services, and self-contained desktop applications. However, there are scenarios where XCOPY is not sufficient as a distribution mechanism. An example is when the application has little private code and relies on the availability of shared assemblies, or when the application is not locally installed (but rather downloaded on demand). For these cases, the .NET Framework provides extensive code download services and integration with the Windows Installer. The code download support provided by the .NET Framework offers several advantages over current platforms, including incremental download, code access security (no more Authenticode dialogs), and application isolation (code downloaded on behalf of one application doesn't affect other applications). The Windows Installer is another powerful deployment mechanism available to .NET applications. All of the features of Windows Installer, including publishing, advertisement, and application repair will be available to .NET applications in Windows Installer 2.0.&lt;br /&gt;&lt;br /&gt;51. I've written an assembly that I want to use in more than one application. Where do I deploy it?&lt;br /&gt;&lt;br /&gt;Assemblies that are to be used by multiple applications (for example, shared assemblies) are deployed to the global assembly cache. In the prerelease and Beta builds, use the /i option to the GACUtil SDK tool to install an assembly into the cache: gacutil /i myDll.dll Windows Installer 2.0, which ships with Windows XP and Visual Studio .NET will be able to install assemblies into the global assembly cache.&lt;br /&gt;&lt;br /&gt;52. How can I see what assemblies are installed in the global assembly cache?&lt;br /&gt;&lt;br /&gt;The .NET Framework ships with a Windows shell extension for viewing the assembly cache. Navigating to % windir%\assembly with the Windows Explorer activates the viewer.&lt;br /&gt;&lt;br /&gt;53. What is an application domain?&lt;br /&gt;&lt;br /&gt;An application domain (often AppDomain) is a virtual process that serves to isolate an application. All objects created within the same application scope (in other words, anywhere along the sequence of object activations beginning with the application entry point) are created within the same application domain. Multiple application domains can exist in a single operating system process, making them a lightweight means of application isolation. An OS process provides isolation by having a distinct memory address space. While this is effective, it is also expensive, and does not scale to the numbers required for large web servers. The Common Language Runtime, on the other hand, enforces application isolation by managing the memory use of code running within the application domain. This ensures that it does not access memory outside the boundaries of the domain. It is important to note that only type-safe code can be managed in this way (the runtime cannot guarantee isolation when unsafe code is loaded in an application domain).&lt;br /&gt;&lt;br /&gt;54. What is garbage collection?&lt;br /&gt;&lt;br /&gt;Garbage collection is a mechanism that allows the computer to detect when an object can no longer be accessed. It then automatically releases the memory used by that object (as well as calling a clean-up routine, called a "finalizer," which is written by the user). Some garbage collectors, like the one used by .NET, compact memory and therefore decrease your program's working set.&lt;br /&gt;&lt;br /&gt;55. How does non-deterministic garbage collection affect my code?&lt;br /&gt;&lt;br /&gt;For most programmers, having a garbage collector (and using garbage collected objects) means that you never have to worry about deallocating memory, or reference counting objects, even if you use sophisticated data structures. It does require some changes in coding style, however, if you typically deallocate system resources (file handles, locks, and so forth) in the same block of code that releases the memory for an object. With a garbage collected object you should provide a method that releases the system resources deterministically (that is, under your program control) and let the garbage collector release the memory when it compacts the working set.&lt;br /&gt;&lt;br /&gt;56. Can I avoid using the garbage collected heap?&lt;br /&gt;&lt;br /&gt;All languages that target the runtime allow you to allocate class objects from the garbage-collected heap. This brings benefits in terms of fast allocation, and avoids the need for programmers to work out when they should explicitly 'free' each object. The CLR also provides what are called ValueTypes—these are like classes, except that ValueType objects are allocated on the runtime stack (rather than the heap), and therefore reclaimed automatically when your code exits the procedure in which they are defined. This is how "structs" in C# operate. Managed Extensions to C++ lets you choose where class objects are allocated. If declared as managed Classes, with the __gc keyword, then they are allocated from the garbage-collected heap. If they don't include the __gc keyword, they behave like regular C++ objects, allocated from the C++ heap, and freed explicitly with the "free" method.&lt;br /&gt;&lt;br /&gt;57. How do in-process and cross-process communication work in the Common Language Runtime?&lt;br /&gt;&lt;br /&gt;There are two aspects to in-process communication: between contexts within a single application domain, or across application domains. Between contexts in the same application domain, proxies are used as an interception mechanism. No marshaling/serialization is involved. When crossing application domains, we do marshaling/serialization using the runtime binary protocol. Cross-process communication uses a pluggable channel and formatter protocol, each suited to a specific purpose. If the developer specifies an endpoint using the tool soapsuds.exe to generate a metadata proxy, HTTP channel with SOAP formatter is the default. If a developer is doing explicit remoting in the managed world, it is necessary to be explicit about what channel and formatter to use. This may be expressed administratively, through configuration files, or with API calls to load specific channels. Options are: HTTP channel w/ SOAP formatter (HTTP works well on the Internet, or anytime traffic must travel through firewalls) TCP channel w/ binary formatter (TCP is a higher performance option for local-area networks (LANs)) When making transitions between managed and unmanaged code, the COM infrastructure (specifically, DCOM) is used for remoting. In interim releases of the CLR, this applies also to serviced components (components that use COM+ services). Upon final release, it should be possible to configure any remotable component. Distributed garbage collection of objects is managed by a system called "leased based lifetime." Each object has a lease time, and when that time expires, the object is disconnected from the remoting infrastructure of the CLR. Objects have a default renew time-the lease is renewed when a successful call is made from the client to the object. The client can also explicitly renew the lease.&lt;br /&gt;&lt;br /&gt;58. Can I use COM objects from a .NET Framework program?&lt;br /&gt;&lt;br /&gt;Yes. Any COM component you have deployed today can be used from managed code, and in common cases the adaptation is totally automatic. Specifically, COM components are accessed from the .NET Framework by use of a runtime callable wrapper (RCW). This wrapper turns the COM interfaces exposed by the COM component into .NET Framework-compatible interfaces. For OLE automation interfaces, the RCW can be generated automatically from a type library. For non-OLE automation interfaces, a developer may write a custom RCW and manually map the types exposed by the COM interface to .NET Framework-compatible types.&lt;br /&gt;&lt;br /&gt;59. Can .NET Framework components be used from a COM program?&lt;br /&gt;&lt;br /&gt;Yes. Managed types you build today can be made accessible from COM, and in the common case the configuration is totally automatic. There are certain new features of the managed development environment that are not accessible from COM. For example, static methods and parameterized constructors cannot be used from COM. In general, it is a good idea to decide in advance who the intended user of a given type will be. If the type is to be used from COM, you may be restricted to using those features that are COM accessible. Depending on the language used to write the managed type, it may or may not be visible by default. Specifically, .NET Framework components are accessed from COM by using a COM callable wrapper (CCW). This is similar to an RCW (see previous question), but works in the opposite direction. Again, if the .NET Framework development tools cannot automatically generate the wrapper, or if the automatic behavior is not what you want, a custom CCW can be developed.&lt;br /&gt;&lt;br /&gt;60. Can I use the Win32 API from a .NET Framework program?&lt;br /&gt;&lt;br /&gt;Yes. Using platform invoke, .NET Framework programs can access native code libraries by means of static DLL entry points. Here is an example of C# calling the Win32 MessageBox function: using System; using System.Runtime.InteropServices; class MainApp { [DllImport("user32.dll", EntryPoint="MessageBox")] public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType); public static void Main() { MessageBox( 0, "Hello, this is PInvoke in operation!", ".NET", 0 ); } }&lt;br /&gt;&lt;br /&gt; 61. What do I have to do to make my code work with the security system?&lt;br /&gt;&lt;br /&gt;Usually, not a thing—most applications will run safely and will not be exploitable by malicious attacks. By simply using the standard class libraries to access resources (like files) or perform protected operations (such as a reflection on private members of a type), security will be enforced by these libraries. The one simple thing application developers may want to do is include a permission request (a form of declarative security) to limit the permissions their code may receive (to only those it requires). This also ensures that if the code is allowed to run, it will do so with all the permissions it needs. Only developers writing new base class libraries that expose new kinds of resources need to work directly with the security system. Instead of all code being a potential security risk, code access security constrains this to a very small bit of code that explicitly overrides the security system.&lt;br /&gt;&lt;br /&gt;62. Why does my code get a security exception when I run it from a network shared drive?&lt;br /&gt;&lt;br /&gt;Default security policy gives only a restricted set of permissions to code that comes from the local intranet zone. This zone is defined by the Internet Explorer security settings, and should be configured to match the local network within an enterprise. Since files named by UNC or by a mapped drive (such as with the NET USE command) are being sent over this local network, they too are in the local intranet zone. The default is set for the worst case of an unsecured intranet. If your intranet is more secure you can modify security policy (with the .NET Framework Configuration tool or the CASPol tool) to grant more permissions to the local intranet, or to portions of it (such as specific machine share names).&lt;br /&gt;&lt;br /&gt;63. How do I make it so that code runs when the security system is stopping it?&lt;br /&gt;&lt;br /&gt;Security exceptions occur when code attempts to perform actions for which it has not been granted permission. Permissions are granted based on what is known about code; especially its location. For example, code run from the Internet is given fewer permissions than that run from the local machine because experience has proven that it is generally less reliable. So, to allow code to run that is failing due to security exceptions, you must increase the permissions granted to it. One simple way to do so is to move the code to a more trusted location (such as the local file system). But this won't work in all cases (web applications are a good example, and intranet applications on a corporate network are another). So, instead of changing the code's location, you can also change security policy to grant more permissions to that location. This is done using either the .NET Framework Configuration tool or the code access security policy utility (caspol.exe). If you are the code's developer or publisher, you may also digitally sign it and then modify security policy to grant more permissions to code bearing that signature. When taking any of these actions, however, remember that code is given fewer permissions because it is not from an identifiably trustworthy source—before you move code to your local machine or change security policy, you should be sure that you trust the code to not perform malicious or damaging actions.&lt;br /&gt;&lt;br /&gt; 64. How do I administer security for my machine? For an enterprise?&lt;br /&gt;&lt;br /&gt;The .NET Framework includes the .NET Framework Configuration tool, an MMC snap-in (mscorcfg.msc), to configure several aspects of the CLR including security policy. The snap-in not only supports administering security policy on the local machine, but also creates enterprise policy deployment packages compatible with System Management Server and Group Policy. A command line utility, CASPol.exe, can also be used to script policy changes on the computer. In order to run either tool, in a command prompt, change the current directory to the installation directory of the .NET Framework (located in %windir%\Microsoft.Net\Framework\v1.0.2914.16\) and type mscorcfg.msc or caspol.exe.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-1890918230945016465?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T10:30:54.762-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/net-framework.html</feedburner:origLink></item><item><title>asp.net faq-7</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/pczF4r8I30g/aspnet-faq-7.html</link><category>ASP.NET</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 04:35:34 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-5615532205428934329</guid><description>&lt;ol style="margin-top: 15px;"&gt;&lt;li&gt; &lt;div align="left"&gt;&lt;b&gt;Describe the role of &lt;i&gt;inetinfo.exe, aspnet_isapi.dll &lt;/i&gt;and&lt;i&gt;aspnet_wp.exe&lt;/i&gt; in the page loading process&lt;/b&gt;.&lt;br /&gt;inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.&lt;br /&gt; &lt;/div&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;What’s the difference between Response.Write() andResponse.Output.Write()?&lt;br /&gt;&lt;/b&gt;Response.Output.Write() allows you to write formatted output.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;What methods are fired during the page load?&lt;br /&gt;&lt;/b&gt;Init() - when the page is instantiated&lt;br /&gt;Load() - when the page is loaded into server memory&lt;br /&gt;PreRender() - the brief moment before the page is displayed to the user as HTML&lt;br /&gt;Unload() - when page finishes loading.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;strong&gt;When during the page processing cycle is ViewState available?&lt;/strong&gt;&lt;br /&gt;After the Init() and before the Page_Load(), or OnLoad() for a control.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;What namespace does the Web page belong in the .NET Framework class hierarchy?&lt;br /&gt;&lt;/b&gt;System.Web.UI.Page&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Where do you store the information about the user’s locale?&lt;br /&gt;&lt;/b&gt;System.Web.UI.Page.Culture&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?&lt;br /&gt;&lt;/b&gt;CodeBehind is relevant to Visual Studio.NET only.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;What’s a bubbled event?&lt;br /&gt;&lt;/b&gt;When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Suppose you want a certain ASP.NET function executed on MouseOver for a certain button.  Where do you add an event handler?&lt;br /&gt;&lt;/b&gt;Add an OnMouseOver attribute to the button.  Example: &lt;span&gt;btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();");&lt;/span&gt;&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;What data types do the RangeValidator control support?&lt;br /&gt;&lt;/b&gt;Integer, String, and Date.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Explain the differences between Server-side and Client-side code?&lt;br /&gt;&lt;/b&gt;Server-side code executes on the server.  Client-side code executes in the client's browser.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;What type of code (server or client) is found in a Code-Behind class?&lt;br /&gt;&lt;/b&gt;The answer is server-side code since code-behind is executed on the server.  However, during the code-behind's execution on the server, it can render client-side code such as JavaScript to be processed in the clients browser.  But just to be clear, code-behind executes on the server, thus making it server-side code.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Should user input data validation occur server-side or client-side?  Why?&lt;br /&gt;&lt;/b&gt;All user input data validation should occur on the server at a minimum.  Additionally, client-side validation can be performed where deemed appropriate and feasable to provide a richer, more responsive experience for the user.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;What is the difference between Server.Transfer and Response.Redirect?  Why would I choose one over the other?&lt;br /&gt;&lt;/b&gt;Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser.  This provides a faster response with a little less overhead on the server.  Server.Transfer does not update the clients url history list or current url.  Response.Redirect is used to redirect the user's browser to another page or site.  This performas a trip back to the client where the client's browser is redirected to the new page.  The user's browser history list is updated to reflect the new address.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?&lt;br /&gt;&lt;/b&gt;&lt;span&gt;Valid answers are:&lt;br /&gt;·&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span&gt;A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.&lt;br /&gt;&lt;/span&gt;&lt;span&gt;·&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span&gt;A DataSet is designed to work without any continuing connection to the original data source.&lt;br /&gt;&lt;/span&gt;&lt;span&gt;·&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span&gt;Data in a DataSet is bulk-loaded, rather than being loaded on demand.&lt;br /&gt;&lt;/span&gt;&lt;span&gt;·&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span&gt;There's no concept of cursor types in a DataSet.&lt;br /&gt;&lt;/span&gt;&lt;span&gt;·&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span&gt;DataSets have no current record pointer You can use For Each loops to move through the data.&lt;br /&gt;&lt;/span&gt;&lt;span&gt;·&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span&gt;You can store many edits in a DataSet, and write them to the original data source in a single operation.&lt;br /&gt;&lt;/span&gt;&lt;span&gt;·&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span&gt;Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.&lt;br /&gt; &lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;strong&gt;What is the Global.asax used for?&lt;br /&gt;&lt;/strong&gt;The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;What are the Application_Start and Session_Start subroutines used for?&lt;br /&gt;&lt;/b&gt;This is where you can set the specific variables for the Application and Session objects.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Can you explain what inheritance is and an example of when you might use it?&lt;br /&gt;&lt;/b&gt;When you want to inherit (use the functionality of) another class.  Example: With a base class named Employee, a Manager class could be derived from the Employee base class.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Whats an assembly?&lt;br /&gt;&lt;/b&gt;Assemblies are the building blocks of the .NET framework.&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconassembliesoverview.asp"&gt; Overview of assemblies from MSDN&lt;/a&gt;&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Describe the difference between inline and code behind.&lt;br /&gt;&lt;/b&gt;Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Explain what a diffgram is, and a good use for one?&lt;br /&gt;&lt;/b&gt;The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML.  A good use is reading database data to an XML file to be sent to a Web Service.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Whats MSIL, and why should my developers need an appreciation of it if at all?&lt;br /&gt;&lt;/b&gt;MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL.  MSIL also allows the .NET Framework to JIT compile the assembly on the installed computer.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Which method do you invoke on the DataAdapter control to load your generated dataset with data?&lt;br /&gt;&lt;/b&gt;The Fill() method.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Can you edit data in the Repeater control?&lt;br /&gt;&lt;/b&gt;No, it just reads the information from its data source&lt;strong&gt;.&lt;/strong&gt;&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Which template must you provide, in order to display data in a Repeater control?&lt;br /&gt;&lt;/b&gt;ItemTemplate.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;How can you provide an alternating color scheme in a Repeater control?&lt;br /&gt;&lt;/b&gt;Use the AlternatingItemTemplate&lt;strong&gt;.&lt;/strong&gt;&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;What property must you set, and what method must you call in your code, in order to bind the data from a data source to the Repeater control?&lt;br /&gt;&lt;/b&gt;You must set the DataSource property and call the DataBind method.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;What base class do all Web Forms inherit from?&lt;br /&gt;&lt;/b&gt;The Page class.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Name two properties common in every validation control?&lt;br /&gt;&lt;/b&gt;ControlToValidate property and Text property.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?&lt;br /&gt;&lt;/b&gt;DataTextField property.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Which control would you use if you needed to make sure the values in two different controls matched?&lt;br /&gt;&lt;/b&gt;CompareValidator control.&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;b&gt;How many classes can a single .NET DLL contain?&lt;br /&gt;&lt;/b&gt;It can contain many classes.&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-5615532205428934329?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T04:35:34.052-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/aspnet-faq-7.html</feedburner:origLink></item><item><title>Debuging-1</title><link>http://feedproxy.google.com/~r/blogspot/qiWo/~3/wRCedudA4kQ/debuging-1.html</link><category>Testing and Debuging</category><author>noreply@blogger.com (ZeroCode)</author><pubDate>Mon, 24 Dec 2007 04:30:02 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-7507827582191619085.post-7434325931933116397</guid><description>&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;Debugging and Testing Questions &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol&gt;&lt;li&gt;&lt;span&gt;&lt;span&gt;&lt;strong&gt;What debugging tools come with the .NET SDK?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;1.&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;CorDBG – command-line debugger.&lt;span&gt;  &lt;/span&gt;To use CorDbg, you must compile the original C# file using the /debug switch.&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;2.&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;DbgCLR – graphic debugger. &lt;span&gt; &lt;/span&gt;Visual Studio .NET uses the DbgCLR.&lt;/span&gt;&lt;br /&gt;  &lt;o:p&gt;&lt;/o:p&gt; &lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;span&gt;&lt;span&gt;What does assert() method do?&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span&gt;In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. &lt;span&gt; &lt;/span&gt;The program proceeds without any interruption if the condition is true.&lt;br /&gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;span&gt;&lt;span&gt;What’s the difference between the Debug class and Trace class?&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span&gt;Documentation looks the same. &lt;span&gt; &lt;/span&gt;Use Debug class for debug builds, use Trace class for both debug and release builds.&lt;br /&gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;span&gt;&lt;span&gt;Why are there five tracing levels in System.Diagnostics.TraceSwitcher?&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span&gt;The tracing dumps can be quite verbose.&lt;span&gt;  &lt;/span&gt;For applications that are constantly running you run the risk of overloading the machine and the hard drive. &lt;span&gt; &lt;/span&gt;Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.&lt;br /&gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span&gt;&lt;strong&gt;Where is the output of TextWriterTraceListener redirected?&lt;/strong&gt;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;span&gt;To the Console or a text file depending on the parameter passed to the constructor.&lt;br /&gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span&gt;&lt;strong&gt;How do you debug an ASP.NET Web application?&lt;/strong&gt;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;span&gt;Attach the aspnet_wp.exe process to the DbgClr debugger.&lt;br /&gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;span&gt;&lt;span&gt;What are three test cases you should go through in unit testing?&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span&gt;&lt;span&gt;1.&lt;span&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;Positive test cases (correct data, correct output).&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;2.&lt;span&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;Negative test cases (broken or missing data, proper handling).&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;3.&lt;span&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;Exception test cases (exceptions are thrown and caught properly).&lt;br /&gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;span&gt;&lt;span&gt;Can you change the value of a variable while debugging a C# application?&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span&gt;Yes.&lt;span&gt;  &lt;/span&gt;If you are debugging via Visual Studio.NET, just go to Immediate window.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7507827582191619085-7434325931933116397?l=bytescode.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T04:30:02.993-08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://bytescode.blogspot.com/2007/12/debuging-1.html</feedburner:origLink></item><media:rating>nonadult</media:rating><media:description type="plain">Dot Net</media:description></channel></rss>

