tag:blogger.com,1999:blog-88210782245939830742008-08-11T15:42:01.377-05:00.Net Interview Questions & AnswersGurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-8821078224593983074.post-3261072550118333082008-04-22T10:20:00.002-05:002008-04-22T10:29:26.914-05:00Now you can ask interview questionA new portal for developer community has been launched. Where you can ask any tech question and get answer from tech experts. You can also discuss on any tech topic.<br /><br />See ASP.Net interview questions discussion at<br /><a href="http://www.techbaba.com/faqs/asp.net+interview+question+answers.aspx"><br /><b>http://www.techbaba.com/faqs/asp.net+interview+question+answers.aspx</b></a><br /><br /><br/>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-3816416104553075652007-06-26T03:22:00.000-05:002007-06-26T03:31:00.962-05:00All type .Net faqs, interview questions & answers<a href="http://www.dotnetinterviewfaqs.com/">http://www.dotnetinterviewfaqs.com/</a> is a new .Net website having all Microsoft related faqs, interview questions & answers<br /><br/><br />To visit click <a href="http://www.dotnetinterviewfaqs.com/">http://www.dotnetinterviewfaqs.com/</a>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-54634812594097574132007-01-25T16:30:00.000-05:002007-02-06T21:38:40.215-05:00Multiple - Language Development in .NET Framework<b>.NET Framework</b> encourages cross-language development using multiple programming languages. To become a .NET language, any language should have a compiler that translates the source code written in different languages into <b>Microsoft Intermediate Language</b> (<b>MSIL</b>). <br /><br /><b>MSIL</b> code is called as <b>Managed Code</b>. Managed code runs in .NET environment.<br /><br />In <b>.Net framework</b> the <b>Common Runtime Language</b> (CLR) contains a couple of <b>just-in-time compilers</b> (<b>JIT</b>) which can understand <b>IL Code</b> (managed Code), and can convert IL to <b>native code</b> (binary code targeted at a specific machine processor).<br /><br />Hence any language with IL Code generating compiler can become a .Net languageGurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-54587666208727681832007-01-11T11:50:00.000-05:002007-02-06T11:48:15.382-05:00Explain the delegates in C#.<b>Delegates in C#</b> are objects which points towards a function which matches its signature. <b>Delegates</b> are reference type used to encapsulate a method with a specific signature. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure.<br />Here are some features of delegates:<ul><li>A delegate represents a class. </li> <li>A delegate is type-safe. </li><li>We can use delegates both for static and instance methods</li><li>We can combine multiple delegates into a single delegate. </li><li>Delegates are often used in event-based programming, such as publish/subscribe. </li><li>We can use <b>delegates</b> in asynchronous-style programming. </li><li>We can define delegates inside or outside of classes. </li></ul>Syntax of using delegates<br /><br />//Declaring delegate <br />delegate void SampleDelegate(string message);<br /><br />// declare method with same signature:<br />static void SampleDelegateMethod(string message) { Console.WriteLine(message); }<br /><br />// create delegate object <br />SampleDelegate d1 = SampleDelegateMethod;<br /><br />// Invoke method with delegate<br /> d1("my program");Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-52401777662063708822007-01-11T09:19:00.000-05:002007-02-06T21:10:48.615-05:00What is the purpose of connection pooling in ADO.NET?<b>Connection pooling</b> enables an application to use a connection from a pool of connections that do not need to be re-established for each use. Once a connection has been created and placed in a <b>connection pool</b>, an application can reuse that connection without performing the complete connection creation process.<br /><br />By default, the <b>connection pool</b> is created when the first connection with a unique connection string connects to the database. The pool is populated with connections up to the minimum pool size. Additional connections can be added until the pool reaches the <b>maximum pool size</b>.<br /><br />When a user request a connection, it is returned from the pool rather than establishing new connection and, when a user releases a connection, it is returned to the pool rather than being released. But be sure than your connections use the same <b>connection string</b> each time. Here is the Syntax<br /><br /><em>conn.ConnectionString = "integrated Security=SSPI; SERVER=192.168.0.123; DATABASE=MY_DB; Min Pool Size=4;Max Pool Size=40;Connect Timeout=14;";</em>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-13465972017134361332007-01-10T11:48:00.000-05:002007-02-06T21:11:32.081-05:00What is the difference between classes and structs in Microsoft.Net?<ul><li>A <b>struct</b> is a value type, while a <b>class</b> is a reference type. </li><li>When we instantiate a class, memory will be allocated on the heap. When struct gets initiated, it gets memory on the stack. </li><li>Classes can have explicit parameter less constructors. But structs cannot have this. </li><li>Classes support inheritance. But there is no inheritance for structs. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Like classes, structures can implement interfaces. </li><li>We can assign null variable to class. But we cannot assign null to a struct variable, since structs are value type. </li> <li>We can declare a destructor in class but can not in struct.</li><br /></ul>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-1516869769833735772007-01-09T11:49:00.000-05:002007-02-06T21:11:59.121-05:00What is a Strong Name in Microsoft.Net?In <b>Microsoft.Net</b> a strong name consists of the assembly's identity. The strong name guarantees the integrity of the assembly. Strong Name includes the name of the <b>.net assembly</b>, version number, culture identity, and a public key token. It is generated from an assembly file using the corresponding private key.<br />Steps to create <b>strong named assembly</b>:<br /><br />To create a <b>strong named assembly</b> you need to have a key pair (public key and a private key) file. Use <strong>sn -k KeyFile.snk</strong><br />Open the dot net project to be complied as a strong named assembly. Open AssembyInfo.cs/ AssembyInfo.vb file. Add the following lines to AssemblyInfo file.<br /><em>[Assembly: AssemblyVersion("1.0.*")]<br />[assembly: AssemblyDelaySign(false)]<br />[assembly: AssemblyKeyFile("..\\..\\KeyFile.snk")]</em><br />Compile the application, we have created a <b>strong named assembly</b>.Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-58479518801648456052007-01-09T11:13:00.000-05:002007-02-06T21:12:25.350-05:00What is the use of XSLT?<b>XSLT stands for Extensible Stylesheet Language Transformations</b>. This language used in <b>XSL style sheets</b> to transform <b>XML documents</b> into other <b>XML documents</b>.<br /><br /><b>XSLT</b> is based on template rules which specify how XML documents should be processed. An <b>XSLT processor</b> reads both an XML document and an <b>XSLT style sheet</b>. Based on the instructions the processor finds in the <b>XSLT style sheet</b>, it produce a new XML document. With XSLT we can also produce HTML or XHTML from XML document. With XSLT we can add/remove elements and attributes, rearrange and sort elements, hide and display elements from the output file. Converting XML to HTML for display is probably the most common application of <b>XSLT</b> today.Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-24655393867379786732007-01-08T10:51:00.000-05:002007-02-06T21:13:03.818-05:00Explain ACID properties of the database?All <b>Database systems</b> which include transaction support implement ACID properties to ensure the integrity of the database. <b>ACID stands for Atomicity, Consistency, Isolation and Durability</b><br /><ul><li><b>Atomicity</b>: Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. Modifications on the data in the database either fail or succeed. </li><li><b>Consistency</b>: This property ensures that only valid data will be written to the database. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back and the database will be restored to a state consistent with those rules. </li><li><b>Isolation</b>: It requires that multiple transactions occurring at the same time not impact each other’s execution. </li><li><b>Durability</b>: It ensures that any <b>transaction</b> committed to the <b>database</b> will not be lost. </li><br /></ul>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-66291363293334664322007-01-08T10:00:00.000-05:002007-02-06T21:13:30.189-05:00What is the basic functionality of Garbage Collector in Microsft.Net?The <b>Common Language Runtime</b> (<b>CLR</b>) requires that you create objects in the managed heap, but you do not have to bother with cleaning up the memory once the object goes out of the scope or is no longer needed. The <b>Microsoft .NET Framework</b> <b>Garbage Collector</b> provides <b>memory management</b> capabilities for <b>managed resources</b>. The Garbage Collector frees objects that are not referenced and reclaims their memory. You should set your references to Nothing(null) as soon as you are done with them to ensure your objects are eligible for collection as soon as possible.<br />Here are the list of some tasks performed by the <b>Garbage collector</b>:<br /><ul><li><b>Garbage collector</b> reserves a piece of memory as the application starts for the <b>managed heap</b>. </li><li><b>Garbage collector</b> controls the managed heap memory currently used and available to an application. </li><li><b>Garbage collector</b> allocates memory for new objects within the application. </li><li>The <b>Garbage Collector</b> attempts to reclaim the memory of objects that are not referenced. </li><br /></ul>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-17821515449401620162007-01-07T09:26:00.000-05:002007-02-06T21:14:00.999-05:00What is a static class?We can declare a <b>static class</b>. We use <b>static class</b> when there is no data or behavior in the class that depends on object identity. A static class can have only static members. We can not create instances of a static class using the new keyword. <b>.NET Framework</b> <b>common language runtime</b> (CLR) loads <b>Static classes</b> automatically when the program or namespace containing the class is loaded.<br /><br />Here are some more features of <b>static class</b><br /><br /><ul><li><b>Static classes</b> only contain <b>static members</b>. </li><li>Static classes can not be instantiated. They cannot contain Instance Constructors </li><li>Static classes are sealed. </li></ul>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-76121930502207200102007-01-07T09:04:00.000-05:002007-02-06T21:14:37.940-05:00What is static member of class?A <b>static member</b> belongs to the class rather than to the instances of the class. In C# data fields, <b>member functions</b>, properties and events can be declared static. When any instances of the class are created, they cannot be used to access the static member.<br />To access a <b>static class member</b>, use the name of the class instead of an instance variable<br />Static methods and Static properties can only access <b>static fields</b> and <b>static events</b>. <br /><br />Like: <em>int i = Car.GetWheels;</em><br />Here <em>Car</em> is class name and <em>GetWheels</em> is <b>static property</b>.<br /><br /><b>Static members</b> are often used to represent data or calculations that do not change in response to object state.Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-87824604802867939942007-01-07T05:28:00.000-05:002007-02-06T21:16:00.817-05:00What is the purpose of Server.MapPath method in Asp.Net?In <b>Asp.Net</b> <b>Server.MapPath</b> method maps the specified relative or <b>virtual path</b> to the corresponding <b>physical path</b> on the server. <b>Server.MapPath</b> takes a path as a parameter and returns the physical location on the hard drive. Syntax<br /><br />Suppose your Text files are located at D:\project\MyProject\Files\TextFiles<br /><br />If the root project directory is MyProject and the aspx file is located at root then to get the same path use code<br /><br />//Physical path of TextFiles<br /><em>string TextFilePath=Server.MapPath("Files/TextFiles");</em>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-53725497372302403122007-01-05T11:41:00.000-05:002007-02-06T21:16:50.568-05:00What is the use of indexes and what are the types of indexes available in SQL Server?<b>Indexes</b> are used to find data quickly when a query is processed in any <b>relational database</b>. <b>Indexes</b> improve performance by 10 to 500 times. <br />Index can improve the performance in following operations:<br /><ul><li>Find the records matching with WHERE clause</li><br /><em>UPDATE Books SET Availability = 1 WHERE SubjectId =12 <br />DELETE FROM Books WHERE Price <10<br />SELECT * FROM Books WHERE Price BETWEEN 50 AND 80</em><br /><li>Sorting the result with ORDER BY</li><br /><em>SELECT * FROM Books ORDER BY Price DESC</em><br /><li>Grouping records and aggregate values</li><br />SELECT Count(*) as Units, Price FROM Books GROUP BY Price<br /></ul>There are two types of indexes available in SQL Server: clustered and non-clustered<br /><b>Clustered index </b><br /><b>Clustered index</b> physically reorders the records of a table. Therefore a table can have only one clustered index. Usually a <b>clustered index</b> will be created on the <b>primary key</b> of a table. <br /><b>Non – Clustered Index</b><br /><b>Non – Clustered index</b> are stored in the order of the index key values, but the information in the table is stored in a different order. Means logical sorting of data not Physical. In SQl Server 2005 a table can have 249 non-clustered indexes.<br /><b>Composite Indexes</b><br />A composite index is an index on two or more columns. Both clustered and non-clustered indexes can be composite indexes. If you have composite index on Price and BookName then take can take advantage of it like this:<br /><em>SELECT BookName, Price FROM Products ORDER BY UnitPrice BookName, Price DESC</em>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-49354723590356195062007-01-04T10:42:00.000-05:002007-02-06T21:17:22.797-05:00What is the difference between abstract class and interface?We use <b>abstract class</b> and <b>interface</b> where two or more entities do same type of work but in different ways. Means the way of functioning is not clear while defining abstract class or interface. When functionality of each task is not clear then we define interface. If functionality of some task is clear to us but there exist some functions whose functionality differs object by object then we declare <b>abstract class</b>.<br />We can not make instance of <b>Abstract Class</b> as well as Interface. They only allow other classes to <b>inherit</b> from them. And <b>abstract functions</b> must be overridden by the implemented classes. Here are some differences in abstract class and interface.<br /><ul><li>An <b>interface</b> cannot provide code of any method or property, just the signature. we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract. An abstract class can provide complete code of methods but there must exist a method or property without body.</li><br /><li>A class can implement several interfaces but can inherit only one abstract class. Means <b>multiple inheritance</b> is possible in .Net through Interfaces. </li><br /><li>If we add a new method to an <b>Interface</b> then we have to define implementation for the new method in every implemented class. But If we add a new method to an abstract class then we can provide default implementation and therefore all the existing code might work properly.</li> </ul>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-38741967193984162422007-01-04T10:37:00.000-05:002007-02-06T21:18:39.679-05:00What is the use of Master Pages in Asp.Net?A <b>master page</b> in <b>ASP.Net</b> provides shared HTML, controls, and code that can be used as a template for all of the pages of a website.<br />Every master page has <b>asp:contentplaceholder</b> control that will be filled by the content of the pages that use this master page. <br />You can create a <b>master page</b> that has header and footer i.e. a logo, an image, left navigation bar etc and share this content on multiple pages. You need not to put these things on every <b>aspx page</b>.<blockquote></blockquote>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-71312145394212647192007-01-03T11:43:00.000-05:002007-02-06T21:19:43.020-05:00What is the difference between .Net Remoting and Asp.Net Web Services?<ul> <li><b>ASP.NET Web Services</b> Can be accessed only over HTTP but .Net Remoting Can be accessed over various protocols like TCP, HTTP, SMTP etc. </li><br /><li>Web Services are based on stateless service architecture but <b>.Net Remoting</b> support for both stateful and stateless environment. </li><br /><li>Web Services support heterogeneous environments means interoperability across platforms but .Net remoting requires .Net on both server and client end. </li><br /><li>.NET Remoting provides the fast communication than <b>Web Services</b> when we use the TCP channel and the <b>binary formatter</b>. </li><br /><li>Web services support only the objects that can be serialized but .NET Remoting can provide support to all objects that inherit MarshalByRefObject. </li><br /><li>Web Services are reliable than <b>.Net remoting</b> because <b>Web services</b> are always hosted in IIS. </li><br /><li>Web Services are ease to create and deploy but <b>.Net remoting</b> is bit complex to program. </li><br /></ul>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-1939896459264840032007-01-03T10:58:00.000-05:002007-02-06T21:30:46.426-05:00What would be the common layers in an n- tier architecture based web application?<b>Common layers</b> in an <b>n- tier architecture</b><ul><li>Presentation GUI: Look & Feel ,Html, aspx file, JavaScript, window forms etc. </li><br /><li>Controller- Work flow layer: aspx.cs file, means event handlers and Data binding with controls etc. </li><br /><li>Business Logic: where we implement business rules like add book, search library etc. </li><br /><li>Data Access: SQLHelper.cs like create connection, get DataSet, Execute Query etc. </li><br /><li>Physical Data: tables, views, stored procedures, indexes etc. </li><br /></ul>Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-28152431638137164602007-01-03T10:55:00.000-05:002007-02-06T21:33:12.958-05:00What are the different state management techniques used in asp.net for web applications?<h3>In ASP.Net the state can be maintained in following ways</h3><b>Server-side state management</b><br />Application objects<br />Session Variables<br />Database<br /><b>Client-side state management</b><br />Cookies<br />Hidden input fields<br />Query String<br />ViewStateGurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-90586583096436504552007-01-03T10:47:00.000-05:002007-02-06T21:34:40.315-05:00How to get records in random order from a sql query in sql server?In <b>SQL Server</b> we can get records in random order from a sql query using NEWID() Function like:<br/><br />SELECT Subject FROM dbo.forumThreads ORDER BY NEWID()Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.com