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.
C# Interview Questions and Answers
1) The C# keyword ?int? maps to which .NET type?
-
System.Int16
-
System.Int32
-
System.Int64
-
System.Int128
2) Which of these string definitions will prevent escaping on backslashes in C#?
-
string s = #?n Test string?;
-
string s = ??n Test string?;
-
string s = @?n Test string?;
-
string s = ?n Test string?;
3) Which of these statements correctly declares a two-dimensional array in C#?
-
int[,] myArray;
-
int[][] myArray;
-
int[2] myArray;
-
System.Array[2] myArray;
4) If a method is marked as protected internal who can access it?
-
Classes that are both in the same assembly and derived from the declaring class.
-
Only methods that are in the same class as the method in question.
-
Internal methods can be only be called using reflection.
-
Classes within the same assembly, and classes derived from the declaring class.
5) What is boxing?
a) Encapsulating an object in a value type.
b) Encapsulating a copy of an object in a value type.
c) Encapsulating a value type in an object.
d) Encapsulating a copy of a value type in an object.
6) What compiler switch creates an xml file from the xml comments in the files in an assembly?
-
/text
-
/doc
-
/xml
-
/help
7) What is a satellite Assembly?
-
A peripheral assembly designed to monitor permissions requests from an application.
-
Any DLL file used by an EXE file.
-
An assembly containing localized resources for another assembly.
-
An assembly designed to alter the appearance or ?skin? of an application.
What is a delegate?
-
A strongly typed function pointer.
-
A light weight thread or process that can call a single method.
-
A reference to an object in a different process.
-
An inter-process message channel.
9) How does assembly versioning in .NET prevent DLL Hell?
-
The runtime checks to see that only one version of an assembly is on the machine at any one time.
-
.NET allows assemblies to specify the name AND the version of any assemblies they need to run.
-
The compiler offers compile time checking for backward compatibility.
-
It doesn?t.
10) Which ?Gang of Four? design pattern is shown below?
public class A {
private A instance;
private A() {
}
public
static A Instance {get
{
if ( A == null )
A = new A();
return instance;
}
}
}
-
Factory
-
Abstract Factory
-
Singleton
-
Builder
10 .NET questions
How do you view the methods and members of a DLL? - What is shadowing?
- How do you load an assembly at runtime?
- If I am writing in a language like VB or C++, what are the procedures to be followed to support .NET?
- Compare Client server application with n-Tier application
- Differences between DLL and EXE?
- Can an assembly have EXE?
- Can a try block have more than one catch block?
- Can a DLL be changed to an EXE?
- Compare & contrast rich client (smart clients or Windows-based) & browser-based Web application
- What are the collections you’ve used?
- Can a try block have nested try blocks?
10 ASP.NET Interview Questions
- How does ViewState work and why is it either useful or evil?
- What is the OO relationship between an ASPX page and its CS/VB code behind file in ASP.NET 1.1? in 2.0?
- What is an assembly binding redirect? Where are the places an administrator or developer can affect how assembly binding policy is applied?
- Compare and contrast LoadLibrary(), CoCreateInstance(), CreateObject() and Assembly.Load().
- What happens from the point an HTTP request is received on a TCP/IP port up until the Page fires the On_Load event?
- What are ASHX files? What are HttpHandlers? Where can they be configured?
- What is needed to configure a new extension for use in ASP.NET? For example, what if I wanted my system to serve ASPX files with a *.jsp extension?
- What events fire when binding data to a data grid? What are they good for?
- How does IIS communicate at runtime with ASP.NET? Where is ASP.NET at runtime in IIS5? IIS6?
- Explain how PostBacks work, on both the client-side and server-side. How do I chain my own JavaScript into the client side without losing PostBack functionality?
.NET Interview Questions on CLR
Overview of CLR integration.
The CLR (Common Language Runtime) integration is hosted in the Microsoft SQL Server 2005.
With CLR integration, stored procedures, triggers, user- defined functions, user-defined types, and user-defined aggregates in managed code, etc can be written.
As managed code compiles to native code before executing, significant performance can be achieved.
The SQL Server acts as an operating system for the CLR when it is hosted inside SQL Server.
Following are the steps to build a CLR stored procedure in SQL Server 2005
* Enable CLR integration in SQL Server 2005
* Create a CLR stored procedure Assembly
* Deploy the Assembly in SQL Server 2005
* Create and execute the CLR stored procedure in SQL Server 2005
Explain CLR in brief.
CLR stands for Common Language Runtime. The CLR is a development platform. It provides a runtime, defines functionality in some libraries, and supports a set of programming languages. The CLR provides a runtime so that the softwares can utilize its services. The CLR Base Class Library allows interaction with the runtime. The CLR supports various programming languages, several standards and is itself been submitted as an open standard.
Describe the parts of assembly.
An assembly is a partially compiled code library. In .NET, an assembly is a portable executable and can be an EXE (process assembly) or a DLL (library assembly). An assembly can consist of one or more files or modules in various languages. It is used in deployment, versioning and security.
What A Mid-Level .NET Developers Ought To Know
continue http://tipsinterview.com/2009/12/21/what-every-net-developers-ought-to-know/
- Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.
- Describe what an Interface is and how it’s different from a Class.
- What is Reflection?
- What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?
- Are the type system represented by XmlSchema and the CLS isomorphic?
- Conceptually, what is the difference between early-binding and late-binding?
- Is using Assembly.Load a static reference or dynamic reference?
- When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?
- What is an Asssembly Qualified Name? Is it a filename? How is it different?
- Is this valid? Assembly.Load("foo.dll");
- How is a strongly-named assembly different from one that isn’t strongly-named?
- Can DateTimes be null?
- What is the JIT? What is NGEN? What are limitations and benefits of each?
- How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?
- What is the difference between Finalize() and Dispose()?
- How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?
- What does this useful command line do? tasklist /m "mscor*"
- What is the difference between in-proc and out-of-proc?
- What technology enables out-of-proc communication in .NET?
- When you’re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?
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.