Interview Tips Interview Tips, Interview Questions and Answers

24Feb/100

Interview questions for C# developers

  1. If I return out of a try/finally in C#, does the code in the finally-clause run? - Yes. The code in the finally always runs. If you return out of the try block, or even if you do a “goto” out of the try, the finally block always runs:

    Both “In Try block” and “In Finally block” will be displayed. Whether the return is in the try block or after the try-finally block, performance is not affected either way. The compiler treats it as if the return were outside the try block anyway. If it’s a return without an expression (as it is above), the IL emitted is identical whether the return is inside or outside of the try. If the return has an expression, there’s an extra store/load of the value of the expression (since it has to be computed within the try block).

  2. Is it possible to inline assembly or IL in C# code? - No.

  3. Is it possible to have a static indexer in C#? - No. Static indexers are not allowed in C#.

  4. I was trying to use an “out int” parameter in one of my functions. How should I declare the variable that I am passing to it? - You should declare the variable as an int, but when you pass it in you must specify it as ‘out’, like the following: int i; foo(out i); where foo is declared as follows: [return-type] foo(out int o) { }

  5. How do you directly call a native function exported from a DLL? -

  6. This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA. For more information, look at the Platform Invoke tutorial in the documentation.

  7. How do I simulate optional parameters to COM calls? - You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.

  8. How do you specify a custom attribute for the entire assembly (rather than for a class)? - Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows:

    using System;[assembly : MyAttributeClass] class X {}

    Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.

12Jan/100

ASP.NET Features and Advantages

ASP.NET is a compiled, .NET-based environment; you can code the applications in any .NET compatible language, including Visual Basic .NET, C#, and JScript .NET. Additionally, the entire .NET Framework is available to any ASP.NET application.

ASP.NET has been designed with scalability in mind, with features specifically tailored to improve performance in clustered and multiprocessor environments. With built in Windows authentication and per-application configuration, you can be assured that your applications are secure. job-interview1(2)

You can use Web Forms or XML Web services when creating an ASP.NET application, or combine both depending on your need. Both of them allows you to use authentication schemes, cache frequently used data, or customize application's configuration.

ASP.Net allows programmers to develop web applications that interface with a database. The advantage of ASP.Net is that it is object-oriented and has many programming tools that allow for faster development and more functionality.

There are 2 aspects of ASP.Net make it fast, compiled code and caching.

Prior to DOT Net Framework, the code was interpreted into machine language when your website visitor views your page. Now, with ASP.Net the code is compiled into machine language before your visitor ever comes to your site.

Caching is the storage of information that will be reused in a memory location for faster access in the future. ASP.Net allows programmers to set up pages or areas of pages that are commonly reused to be cached for a set period of time to improve the performance of web applications. I have used caching in many of my applications with few records, static and frequently used data.

ASP.Net automatically recovers from memory leaks and errors to make sure that your website is always available to your visitors. Programmers can actually write their code in any of the supported .Net languages like VB.Net, C#, and JScript.Net. In the Learning series, we will be using C# since it’s the widely used language across many companies.

An ASP.NET Framework application is deployed to a server simply by copying the necessary files to the server. No server restart is required, even to deploy or replace running compiled code.

Security is one of the major advantage, you can use built in Windows authentication and also you can set the security configuration by application.

18Dec/090

Top 19 Basic .NET and ASP.NET interview questions

  1. How many languages .NET is supporting now?
    - When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported.
  2. How is .NET able to support multiple languages?
    - a language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.
  3. How ASP .NET different from ASP?
    - Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.
  4. What is smart navigation?
    - The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.
  5. What is view state?
    - The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control
  6. Explain the life cycle of an ASP .NET page.
  7. How do you validate the controls in an ASP .NET page?
    - Using special validation controls that are meant for this. We have Range Validator, Email Validator.
  8. Can the validation be done in the server side? Or this can be done only in the Client side?
    - Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.
  9. How to manage pagination in a page?
    - Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.
  10. What is ADO .NET and what is difference between ADO and ADO.NET?
    - ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.