Interview Tips Interview Tips, Interview Questions and Answers

9Jul/100

Describe the basic schema of a .config file.

Configuration File Schema for the .NET Framework

Configuration Files are standard XML files.

The elements that implement configuration settings are:
<configuration> Element is the top-level element for all configuration files.
<assemblyBinding> Element specifies assembly binding policy at the configuration level.
<linkedConfiguration> Element specifies a configuration file to include.

The configuration schema is for the machine configuration file, application configuration files, and the security configuration file. The following schemas describe their element purposes:

  • Startup Settings Schema – specification of version of the CLR to be used.
  • Runtime Settings Schema – configuration of assembly binding and runtime behavior.
  • Network Settings Schema – specification of .NET connection to the Internet. \
  • Cryptography Settings Schema - mapping friendly algorithm names to classes that implement cryptography algorithms.
  • Configuration Sections Schema - creation and use of configuration sections for custom settings.
  • Trace and Debug Settings Schema – specification of trace switches and listeners.
  • Compiler and Language Provider Settings Schema – specification of compiler configuration for available language providers.
  • Application Settings Schema – enabling Windows Forms or ASP.NET applications to store and retrieve application-scoped and user-scoped settings.
30Apr/100

Explain the concepts and capabilities of Assembly in .NET.

An assembly is a collection of files (dll’s, exe’s), group of resources that help in creating a logical unit of functionality. It forms the basic building block for deployment, reusability and security issues.

  • It provides a CLR environment.
  • It helps in maintaining security as it grants grant or denial of permissions.
  • When an application starts only assemblies the application initially calls must be present.
  • Assemblies can be either static or dynamic.
  • Assemblies help in resolving versioning issues.
17Apr/100

.NET interview: The concepts and capabilities of Assembly in .NET.

An assembly is a collection of files (dll’s, exe’s), group of resources that help in creating a logical unit of functionality. It forms the basic building block for deployment, reusability and security issues.

  • It provides a CLR environment.
  • It helps in maintaining security as it grants grant or denial of permissions.
  • When an application starts only assemblies the application initially calls must be present.
  • Assemblies can be either static or dynamic.
  • Assemblies help in resolving versioning issues.
20Mar/101

What are different types of directives in .NET?

@Page: Defines page-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .aspx files <%@ Page AspCompat="TRUE" language="C#" %>
@Control:Defines control-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .ascx files. <%@ Control Language="VB" EnableViewState="false" %>
@Import: Explicitly imports a namespace into a page or user control. The Import directive cannot have more than one namespace attribute. To import multiple namespaces, use multiple @Import directives. <% @ Import Namespace="System.web" %>
@Implements: Indicates that the current page or user control implements the specified .NET framework interface.<%@ Implements Interface="System.Web.UI.IPostBackEventHandler" %>
@Register: Associates aliases with namespaces and class names for concise notation in custom server control syntax.<%@ Register Tagprefix="Acme" Tagname="AdRotator" Src="AdRotator.ascx" %>
@Assembly: Links an assembly to the current page during compilation, making all the assembly's classes and interfaces available for use on the page. <%@ Assembly Name="MyAssembly" %><%@ Assembly Src="MySource.vb" %>
@OutputCache: Declaratively controls the output caching policies of an ASP.NET page or a user control contained in a page<%@ OutputCache Duration="#ofseconds" Location="Any | Client | Downstream | Server | None" Shared="True | False" VaryByControl="controlname" VaryByCustom="browser | customstring" VaryByHeader="headers" VaryByParam="parametername" %>
@Reference: Declaratively indicates that another user control or page source file should be dynamically compiled and linked against the page in which this directive is declared.

18Mar/100

asp.net interview questions and answers

How do we do paging in gridview?
Make Allowpaging=true also specify the PageIndex as some value

Namespace and Assembly?
Namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.

Diff b/w dataset.clone and dataset.copy
dataset.clone copies just the structure of dataset (including all the datatables, schemas, relations and constraints.); however it doesn’t copy the data. On the other hand dataset.copy, copies both the dataset structure and the data.

Diff b/w Const and readonly?
A const can not be static, while readonly can be static.

A const need to be declared and initialized at declaration only, while a readonly can be initialized at declaration or by the code in the constructor.

A const’s value is evaluated at design time, while a readonly’s value is evaluated at runtime.

Diversities between static or dynamic assemblies ?
Assemblies can be static or dynamic.

Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on).

Static assemblies are stored on disk in portable executable (PE) files.

You can also use the .NET Framework to create dynamic assemblies, which are run directly from memory and are not saved to disk before execution.You can save dynamic assemblies to disk after they have executed.

How can you show the number of visitors of your app
By havving an application variable and Incrementing it in every session start.
TO Achieve it use the Global.asax file's Application_Start and Session_Start Events.

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.

12Mar/100

simple C# interview question that most developer fails

How do you define a property read only for the outside world and writable for the same assembly classes?

For example I have a class named User where everyone outside the assembly can read the string ‘Name’ property but cannot set it. However the classes inside the assembly is able to set the property.  I am further detailing the exlanation.

User myUser = SomeClass.GetUser();

// OK for all classes since all can read it
string name = myUser.Name;   

// This line does not compile if this code is
// written in a class that is not in the same
// assembly as the type User. But it compiles
// if the code is written in the same assembly
// that contains the type user.
myUser.Name = "C# Developer";

Answer:

Now all I want is the c# code declaration for the property name that matches my requirement of being read only for the outside world. Write it in the comments section. I will answer the question 24 hours from now.

1Mar/100

What are different types of directives in .NET?

@Page: Defines page-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .aspx files <%@ Page AspCompat="TRUE" language="C#" %>
@Control:Defines control-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .ascx files. <%@ Control Language="VB" EnableViewState="false" %>
@Import: Explicitly imports a namespace into a page or user control. The Import directive cannot have more than one namespace attribute. To import multiple namespaces, use multiple @Import directives. <% @ Import Namespace="System.web" %>
@Implements: Indicates that the current page or user control implements the specified .NET framework interface.<%@ Implements Interface="System.Web.UI.IPostBackEventHandler" %>
@Register: Associates aliases with namespaces and class names for concise notation in custom server control syntax.<%@ Register Tagprefix="Acme" Tagname="AdRotator" Src="AdRotator.ascx" %>
@Assembly: Links an assembly to the current page during compilation, making all the assembly's classes and interfaces available for use on the page. <%@ Assembly Name="MyAssembly" %><%@ Assembly Src="MySource.vb" %>
@OutputCache: Declaratively controls the output caching policies of an ASP.NET page or a user control contained in a page<%@ OutputCache Duration="#ofseconds" Location="Any | Client | Downstream | Server | None" Shared="True | False" VaryByControl="controlname" VaryByCustom="browser | customstring" VaryByHeader="headers" VaryByParam="parametername" %>
@Reference: Declaratively indicates that another user control or page source file should be dynamically compiled and linked against the page in which this directive is declared.