Interview Tips Interview Tips, Interview Questions and Answers

13Aug/100

Debug Vs Trace in VSTS

Debug Vs Trace.

Both these objects are found in the System.Diagnostics namespace.
Both are used for diagnose problems without interrupting application execution.
Debug statement can only be used in debug mode while trace statement can be used both in debug and released mode.
Debug statements can't be compiled into a release version.

Define trace class.

The trace class in the code is used to diagnose problem.
You can use trace messages to your project to monitor events in the released version of the application.
The trace class is found in the System.Diagnostics namespace.

20May/100

.NET interview: What is the difference between a Thread and Process?

A process is a collection of virtual memory space, code, data, and system resources. A thread is code that is to be serially executed within a process. A processor executes threads, not processes, so each application has at least one process, and a process always has at least one thread of execution, known as the primary thread. A process can have multiple threads in addition to the primary thread. Prior to the introduction of multiple threads of execution, applications were all designed to run on a single thread of execution.

When a thread begins to execute, it continues until it is killed or until it is interrupted by a thread with higher priority (by a user action or the kernel’s thread scheduler). Each thread can run separate sections of code, or multiple threads can execute the same section of code. Threads executing the same block of code maintain separate stacks. Each thread in a process shares that process’s global variables and resources.

13Mar/100

C# interview questions and answers

1. What’s the advantage of using System.Text.StringBuilder over System.String?

StringBuilder is more efficient in cases where a large amount of manipulation is done in the text. Strings are immutable, so it is increasingly being operated, a new instance is created.

2. Can you store multiple data types in System.Array?

No.

3. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?

The first three performs a deep copy of the array, the second three is shallow.

4. How can you sort the elements of the array in descending order?

By calling Sort() and then Reverse() methods.

5. What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?

A catch block that catches the exception of type Process.Exception. You can also omit the parameter information type in this case and write catch {}.

6. Why is it a bad idea to throw your own exceptions?

Well, if that point is known that an error has occurred, why not write the code of law to resolve this error, instead of passing a new Exception object to the catch block? Start your own exclusions means that some design flaws in the project.

7. What’s a delegate?

A delegate object encapsulates a reference to a system. In C++ they were referred to as function pointers.

8. How’s the DLL Hell problem solved in .NET?

Assembly versions allows the application to specify not only the library it needs to function (which was available under Win32), but also the version of the Assembly.

9. What are the ways to deploy an assembly?

An MSI installer, a CAB archive, and XCOPY command.

10. What’s a satellite assembly?

When writing a multilingual application in multi-cultural. NET, and need to deliver the core application separately from the localized modules, the localized assemblies that change the core application are called satellite assemblies.

11. What’s the difference between // comments, /* */ comments and /// comments?

Single-line, multi-line and XML documentation comments.

12. How do you generate documentation from the C# file commented properly with a command-line compiler?

Compile it with a /doc switch.

13. What’s the difference between <c> and <code> XML documentation tag?

Single line code example and multiple-line code example.

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.