You are on page 1of 31

C# Interview Questions This is a list of questions I have gathered from other sources and created myself over a period

of time from my experience, many of which I felt where incomplete or simply wrong. I have finally taken the time to go through each question and correct them to the best of my ability. However, please feel free to post feedback to challenge, improve, or suggest new questions. I want to thank those of you that have contributed quality questions and corrections thus far. There are some questions in this list that I do not consider to be good questions for an interview. However, they do exist on other lists available on the Internet so I felt compelled to keep them easy access. General Questions

The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.

11. How can you sort the elements of the array in descending order?
By calling Sort() and then Reverse() methods.

12. What’s the .NET collection class that allows an element to be accessed
using a unique key? HashTable.

1. 2. 3. 4. 5. 6.

13. What class is underneath the SortedList class?
Does C# support multiple-inheritance? No. Who is a protected class-level variable available to? It is available to any sub-class (a class inheriting this class). Are private class-level variables inherited? Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited. Describe the accessibility modifier “protected internal”. It is available to classes that are within the same assembly and derived from the specified base class. What’s the top .NET class that everything is derived from? System.Object. What does the term immutable mean? The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory. What’s the difference between System.String and System.Text.StringBuilder classes? System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed. What’s the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created. Can you store multiple data types in System.Array? No. A sorted HashTable.

14. Will the finally block get executed if an exception has not occurred?
Yes.

15. What’s the C# syntax to catch any possible exception?
A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.

16. Can multiple catch blocks be executed for a single try statement?
No. Once the proper catch block processed, control is transferred to the finally block (if there are any).

17. Explain the three services model commonly know as a three-tier
application. Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).

Class Questions

7.

1. 2. 3. 4.

What is the syntax to inherit from a class in C#? Place a colon and then the name of the base class. Example: class MyNewClass : MyBaseClass Can you prevent your class from being inherited by another class? Yes. The keyword “sealed” will prevent the class from being inherited. Can you allow a class to be inherited, but prevent the method from being over-ridden? Yes. Just leave the class public and make the method sealed. What’s an abstract class? A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.

8.

9.

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

5.

When do you absolutely have to declare a class as abstract? 1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden. 2. When at least one of the methods in the class is abstract. What is an interface class? Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes. Why can’t you specify the accessibility modifier for methods inside the interface? They all must be public, and are therefore public by default. Can you inherit multiple interfaces? Yes. .NET does support multiple interfaces. What happens if you inherit multiple interfaces and they have conflicting method names? It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay. To Do: Investigate

keyword virtual is changed to keyword override)

5. 6.

What are the different ways a method can be overloaded? Different parameter data types, different number of parameters, different order of parameters. If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor? Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

6.

7. 8. 9.

Events and Delegates

1. 2.

What’s a delegate? A delegate object encapsulates a reference to a method. What’s a multicast delegate? A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.

10. What’s the difference between an interface and abstract class?
In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers.

XML Documentation Questions

1. 2. 3.

Is XML case-sensitive? Yes. What’s the difference between // comments, /* */ comments and /// comments? Single-line comments, multi-line comments, and XML documentation comments. How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with the /doc switch.

11. What is the difference between a Struct and a Class?
Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit.

Method and Property Questions

1.

What’s the implicit name of the parameter that gets passed into the set method/property of a class? Value. The data type of the value parameter is defined by whatever data type the property is declared as. What does the keyword “virtual” declare for a method or property? The method or property can be overridden. How is method overriding different from method overloading? When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class. Can you declare an override method to be static if the original method is not static? No. The signature of the virtual method must remain the same. (Note: Only the

Debugging and Testing Questions

2. 3.

1.

What debugging tools come with the .NET SDK? 1. CorDBG – command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch. 2. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. What does assert() method do? In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.

2.

4.

3. 4.

What’s the difference between the Debug class and Trace class? Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds. Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities. Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor. How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger. What 1. 2. 3. are three test cases you should go through in unit testing? Positive test cases (correct data, correct output). Negative test cases (broken or missing data, proper handling). Exception test cases (exceptions are thrown and caught properly).

5. 6.

What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and password). Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted? Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction. What does the Initial Catalog parameter define in the connection string? The database name to connect to. What does the Dispose method do with the connection object? Deletes it from the memory. To Do: answer better. The current answer is not entirely correct. What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings. The connection string must be identical.

5. 6. 7.

7. 8. 9.

8.

Can you change the value of a variable while debugging a C# application? Yes. If you are debugging via Visual Studio.NET, just go to Immediate window.

Assembly Questions ADO.NET and Database Questions

1. 1. 2.
What is the role of the DataReader class in ADO.NET connections? It returns a read-only, forward-only rowset from the data source. A DataReader provides fast access when a forward-only sequential read is needed. What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix. OLE-DB.NET is a .NET layer on top of the OLE layer, so it’s not as fastest and efficient as SqlServer.NET. What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’. Explain ACID rule of thumb for transactions. A transaction must be: 1. Atomic - it is one unit of work and does not dependent on previous and following transactions. 2. Consistent - data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t. 3. Isolated - no transaction sees the intermediate results of the current transaction). 4. Durable - the values persist if the data had been committed even if the system crashes right after.

How is the DLL Hell problem solved in .NET? Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly. What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command. What is a satellite assembly? When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies. What namespaces are necessary to create a localized application? System.Globalization and System.Resources. What is the smallest unit of execution in .NET? an Assembly. When should you call the garbage collector in .NET? As a good rule, you should not call the garbage collector. However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory. However, this is usually not a good practice. How do you convert a value-type to a reference-type? Use Boxing.

2. 3.

3.

4. 5. 6.

4.

7.

ODBC. Use Debug class for debug builds. Strings are immutable. In C++ they were referred to as function pointers. then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project. 30.String? StringBuilder is more efficient in the cases. What does assert() do? In debug compilation. you must compile the original C# file using the /debug switch. Isolated (no transaction sees 16. How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods. 25. DB2. Five levels range from None to Verbose. Visual Studio .Text. The wildcard character is %. and then whatever follows the finally block.Array. What’s the C# equivalent of C++ catch (…). Will finally block get executed if the exception had not occurred? Yes. assert takes in a Boolean condition as a parameter. What’s the difference between the System. 7. What’s the role of the DataReader class in ADO. What’s the . once the proper catch code fires off. and XCOPY command. How do you debug an ASP. Why is it a bad idea to throw your own exceptions? Well. allowing to fine-tune the tracing activities. proper handling). What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all employees whose name starts with La. the localized assemblies that modify the core application are called satellite assemblies. 9. What are the ways to deploy an assembly? An MSI installer. so not the fastest thing in the world. Explain the three services model (three-tier application). What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods. and shows the error dialog if the condition is false. OLE-DB. 21. System. exception test cases (exceptions are thrown and caught properly). To use CorDbg. 31. know that an error has occurred. 23. 22. a new instance is created. 13. if you are debugging via Visual Studio. 5. 24.NET SDK? CorDBG – command-line debugger. What’s the difference between the Debug class and Trace class? Documentation looks the same. business (logic and underlying code) and data (from storage or other sources). The program proceeds without any interruption if the condition is true.TraceSwitcher? The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there.StringBuilder over System. What’s the difference between // comments. Unboxing converts a reference-type to a value-type.Diagnostics. if at that point you 11. but it’s a . What’s the difference between <c> and <code> XML documentation tag? Single line code example and multiple-line code example.Array. What namespaces are necessary to create a localized application? System. 3. What’s a satellite assembly? When you write a multilingual or multi-cultural application in . 14. You can also omit the parameter data type in this case and just write catch {}. 12. multi-line and XML documentation comments. Explain ACID rule of thumb for transactions. 15.Resources.NET is universal for accessing other sources. What’s the advantage of using System. What’s class SortedList underneath? A sorted HashTable. no “in-between” case where something has been updated and something hasn’t). Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor. Can multiple catch blocks be executed? No.NET uses the DbgCLR.NET Web application? Attach the aspnet_wp. 8. 27. 34. How’s the DLL Hell problem solved in . but requires SQL Server license purchased from Microsoft. thus storing the object on the heap. 10. Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions). /* */ comments and /// comments? Single-line. the control is transferred to the finally block (if there are any). 33. Consistent (data is either committed or roll back. negative test cases (broken or missing data. 29.NET datatype that allows the retrieval of data by a unique key? HashTable.Globalization. 28. 18. 2. What are advantages and disadvantages of Microsoft-provided data provider classes in ADO. Presentation (UI). Why are there five tracing levels in System.NET. where a lot of manipulation is done to the text.exe process to the DbgClr debugger. just go to Immediate window. Can you store multiple data types in System. the proper query with LIKE would involve ‘La%’. How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with a /doc switch. and DbgCLR – graphic debugger. Microsoft Access and Informix.CopyTo() and System. 6. thus storing the value on the stack.NET layer on top of OLE layer.NET? SQLServer. 19.NET? Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32). use Trace class for both debug and release builds.NET.Exception.Array? No. 4. What happens in memory when you Box and Unbox a value-type? Boxing converts a value-type to a reference-type. Object’s instance data is shown. so each time it’s being operated on. the second one is shallow. What debugging tools come with the . Can you change the value of a variable while debugging a C# application? Yes. but also the version of the assembly. correct output). which was a catch-all statement for any possible exception? A catch block that catches the exception of type System. 1. so <Student> and <student> are different elements. 17.NET data provider is high-speed and robust.NET connections? It returns a read-only dataset from the data source when the command is executed. like Oracle. Advanced C# interview questions 20. a CAB archive. 26. Is XML case-sensitive? Yes.NET is a deprecated layer provided for backward compatibility to ODBC engines. What are three test cases you should go through in unit testing? Positive test cases (correct data. What does the This window show in the debugger? It points to the object that’s pointed to by this reference. What’s a delegate? A delegate object encapsulates a reference to a method. . and want to distribute the core application separately from the localized modules.8.Clone()? The first one performs a deep copy of the array. 32.

fields and properties. The procedure is to write test cases for all functions and methods so that whenever a change causes a regression.htm Q15: What is mutable type ? immutable type ? A15: Immutable type are types whose instance data. These are some Interview Questions with suggested answers we collected in MiddleEast-Developers. Nullable types.aspx Q3: Describe the Asp.com/msdnmag/issues/02/09/HTTPPipelines/ Q4: Describe the accessibility modifier protected internal A4: Members are accessible to derived classes and classes within the same Assembly Q5: Difference between an interface and abstract class? A5: In the interface all methods must be abstract. Generics. you can check the group. the SQL Server authentication is untrusted.asp. http://ajax. Windows Presentation Foundation (WPF) and Windows Card Space (WCS) is right. so for more information see this.microsoft. new web controls will be ok. etc) and Master Pages. because it is a value type (Struct) Q2: Describe the Asp.com/en-us/library/ms178472.and post-processing to extend a WebMethod ? A6: Use SOAP extensions .com/webservices/webservices/building/wse/default. how can you multiply a number x by 8? A19: Shift x to the left 3 times. is correct Q19: Without using the multiplication or addition operations. Durable (the values persist if the data had been committed even if the system crashes right after).aspx Q12: What is AJAX ? A12: Asynchronous Javascript And XML Q13:What is NUnit.microsoft. it can be quickly identified and fixed. fields and properties. 37.the intermediate results of the current transaction). What does the parameter Initial Catalog define inside Connection String? The database name to connect to.microsoft.net AJAX Extensions) ? A9: for more information check here.net Q10: What do you know about Agile software methodologies? A10: http://en.net 2. What does Dispose method do with the connection object? Deletes it from the memory. Most Reference Types are mutable.microsoft. along with general programming questions Hey.. What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords).0? A18: Any answer that introduces stuff like.Net & C# Interview question. 35. . Anonymous Methods. 41. or What is Unit testing? A13: Unit testing: is a procedure used to validate that a particular module of source code is working properly from each modification to the next. NUnit is a famous tool for Unit Testing in . These questions are collected by • • • • Adel Khalil Yehia Megahed Hisham Abd El-Hafez Mohammed Hossam Q1: Can DateTime variables be null? A1: No.0 & C# 2. Code Beside model. since SQL Server is the only verifier participating in the transaction. Why would you use untrusted verificaion? Web Services might use it.wikipedia.org/wiki/Agile_software_development Q11: What do you know about Web Services Enhancements (WSE)? A11: http://msdn. Q7: What are Design Patterns? A7: It is a big topic in Object Oriented.com/issue/020417. Q6: How do you perform pre. where every parameter is the same.net Q14: What is an Asp. This type of testing is mostly done by the developers.Access.net Http Handler & Http Module? A14: http://www.. etc. but the mutable type are A type whose instance data. . Most value types are immutable. does not change after the instance is created. can be changed after the instance is created. in the abstract class some methods can be concrete. each test case is separate from the others. it is avaliable through out the Asp.net 1.. In the interface no accessibility modifiers are allowed. Q16: What is the HttpContext Object? Where is it accessible? A16: It's is an Object that Encapsulates all HTTP-specific information about an individual HTTP request. Q17: What is the difference between String & StringBuilder classes? A17: String is an immutable type while StringBuilder is a mutable type Q18: What's the difference between C# 1. x << 3.net request pipline. constructs such as mock objects can assist in separating unit tests.com/Patterns/Patterns. as well as non-Windows applications. role provider . Ideally. Windows Workflow Foundation (WF).com/msdnmag/issues/04/03/ASPColumn/ Q20: What is the difference between ASP.15seconds. Which one is trusted and which one is untrusted? Windows Authentication is trusted because the username and password are checked with the Active Directory. 38. which is ok in abstract classes.0 ? A20: Any answer that include stuff like Provider model (membership provider.0 ? A8: any answer that introduces Windows Communication Foundation (WCF). 39. 40. because every shift left multiplies the number by 2 36. for more questions in other fields like C++. also you can mention that it was originally called WinFX Q9: What do you know about ATLAS (Microsoft ASP.. Iterators .net framework 3. What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection..net Page Life Cycle? A2: http://msdn2. What’s the data provider name to connect to Access database? Microsoft.net pipeline ? Give an Example when you need to extend it? How do you do so? A3: http://msdn. http://dofactory.x & ASP.aspx Q8: What do you know about .http://msdn. including the security settings..

3. What is the default accessibility for a class? internal for a top level class. Iexample2 { public ABSExample() 7. What is protected accessibility? 11. what is the keyword used when Access is restricted to types derived from the containing class. 1. struct. explicit. and an abstract class.Written by Riley Perry from Distributed Development OK – here we go. null. object. Can the members of an interface be private? There are no access restrictions. 6. What is private accessibility? Access is restricted to within the containing class. 10. Write some code using interfaces. 12. } public abstract class ABSExample : Iexample1. No. the answers to the first 173. Methods must declare a return type. this private 9. 8. new. 5. nothing is returned from the method? 4. extern. What is public accessibility? 10. What is protected internal accessibility? Access is restricted to types derived from the containing class or from files within the same assembly. event. 12. 9. 13. public 8. public interface Iexample1 { int MyMethod1(). 7. private for a nested one. 2. virtual methods. . 6. 3. 4. 13. Name 10 C# keywords. 11. What is internal accessibility? void A member marked internal is only accessible from files within the same assembly. } public interface Iexample2 { int MyMethod2(). What is the default accessibility for members of a struct? 2. base. abstract. What is the default accessibility for members of an interface? 1. using System. Class methods to should be marked with what keyword? static 5.

} public virtual void VIRTMethod2() { System.WriteLine("VIRTMethod2 has been overridden"). } public int MyMethod2() { return 2. } public override void MyABSMethod() { System. } public int MyMethod1() { return 1.Console. } } public class FinalClass : VIRTExample { public override void VIRTMethod2() { System.Console.WriteLine("VIRTMethod1 has NOT been overridden").WriteLine("ABSExample constructor").WriteLine("VIRTExample constructor").Console. } public class VIRTExample : ABSExample { public VIRTExample() { System. } public abstract void MyABSMethod().WriteLine("VIRTMethod2 has NOT been overridden").{ System.WriteLine("Abstract method made concrete"). } public virtual void VIRTMethod1() { System.Console.Console. } } .Console.

WriteLine(tv2). 18. int tv2 = 1.WriteLine(tr1. Console.g: using System.TestValue).TestValue = "Original value". TestRef tr2 = new TestRef().TestValue = "New value". int i) { } namespace Console1 { class Class1 { static void Main(string[] args) { TestRef tr1 = new TestRef().ReadLine(). tr1Parm. TestRef tr2Parm) { tv1Parm = 2. tr2Parm. 15. int tv2Parm. Console. ref TestRef tr1Parm. tv2. ref tr1. TestRefVal(ref tv1. tr2. tv2Parm = 2.WriteLine(tr2. e.18. how does this work? Reference parameters reference the original object whereas value parameters make a local copy and do not affect the original. static public void TestRefVal(ref int tv1Parm. 14. tr2).WriteLine("Hello world"). } } } class TestRef { public string TestValue. 16. } } 17. What is a reference parameter? 14. What are the two return types for main? void and int The output for this is: 2 1 New value New value .TestValue). public static void Main(string[] args) { // // TODO: Add code to start application here // } private void Main(string[] args. 17. tr1. } } Console. Some example code is shown: Only one of them is run. A class can have many mains.WriteLine(tv1).TestValue = "Original value".TestValue = "New value". int tv1 = 1. Does an object need to be made to run main? 16. Write a hello world console application. Console. No Console. 15. namespace Console1 { class Class1 { [STAThread] // No longer needed static void Main(string[] args) { Console. that is the one marked (public) static. } using System.

22.ReadLine(). } 28.2. 19. Delegates can point to static or/and member functions. Write some code to use a delegate. A constructor performs initialisation for an object (including the struct type) or class.4).ToString()). 24. 24. 25.19. What is recursion? Recursion is when a method calls itself. Can you use access modifiers with destructors? 27. Reference parameters must be initialised but out gives a reference to an uninstanciated object. myDelegate d = new myDelegate(myInstance. static void Main(string[] args) { MyClass myInstance = new MyClass(). 28. 21. Write code to show how a method can accept a varying number of parameters. This is called when the garbage collector discovers that the object is unreachable. 23. namespace Console1 { class Class1 { delegate void myDelegate(int parameter1).3. Member function with a parameter using System. // <--. If I have a constructor with a parameter. What is an out parameter? An out parameter allows an instance of a parameter object to be made inside a method. It is actually an override for Finalize().Calling function without knowing its name. Console.AMethod). 27. do I need to explicitly create a default constructor? Yes 20. 25. A delegate is a variable that calls a method indirectly."example"). 23.WriteLine(o. without knowing its name. What is a constructor? d(1). Finalize() is called before any memory is reclaimed. 26. 22. What is an overloaded method? An overloaded method has multiple signatures that are different. 20. What is a destructor? using System. 26. namespace Console1 { class Class1 { static void Main(string[] args) { ParamsMethod(1. } static void ParamsMethod(params object[] list) { foreach (object o in list) { Console. ParamsMethod(1. } } } No A C# destuctor is not like a C++ destructor. What is a delegate? A delegate in C# is like a function pointer in C or C++. . 21. It is also possible to use a multicast delegate to point to multiple functions.

WriteLine(param1).ReadLine(). } static void Test2(myDelegate d) { d(2). Events use a publisher/subscriber model. 31. static event myDelegate myEvent. namespace Console1 { class Class1 { delegate void myDelegate(int parameter1). } } } 29. also . } static void Main(string[] args) { MyClass myInstance = new MyClass(). } } class MyClass { public void AMethod(int param1) { Console.WriteLine(param1). Are events synchronous of asynchronous? Asynchronous Multicast delegate calling static and member functions using System. static void AStaticMethod(int param1) { Console.WriteLine(param1). //both functions will be run. Console. What is that? Objects publish events to which other applications subscribe.WriteLine(param1).Calling function without knowing its name. } static void Main(string[] args) { MyClass myInstance = new MyClass(). When the publisher raises an event all subscribers to that event are notified. } } } 32. 29. 32. Console. using System. .Test2(d). static void AStaticMethod(int param1) { Console. What is an event? See 32 31. d += new myDelegate(myInstance. namespace Console1 { class Class1 { delegate void myDelegate(int parameter1). myEvent += new myDelegate(AStaticMethod). // <--. 33.AMethod).AMethod). myDelegate d = null. d += new myDelegate(AStaticMethod). d(1).here's some code for a publisher with multiple subscribers. 30. Can a subscriber subscribe to more than one publisher? Yes.ReadLine(). What is a delegate useful for? The main reason we use delegates is for use in event driven programming. myEvent += new myDelegate(myInstance. 33. 30. } } class MyClass { public void AMethod(int param1) { Console.

int. } } } public class TimeEventArgs : EventArgs { public TimeEventArgs(int second) { seconds += second. what does this mean? . or something else? Unicode 38. cl.instanceSeconds). TimeEventArgs time). double 36. dereferencing the pointer takes more time than directly accessing the direct memory location of a value type.WriteLine("Subscriber1:" + time. What is a value type and a reference type? A reference type is known by a reference to a memory location on the heap. A reference type is essentially a pointer. 35. // add some subscribers 34. } public class MainClass { static void Main(string[] args) { Clock cl = new Clock(). } } class MyClass { public void AMethod(int param1) { Console. } private static int seconds. Is string Unicode. } public static void Subscriber2(object clockInstance. public int instanceSeconds. Name 5 built in types. } } } namespace EventExample { public class Clock { public delegate void TwoSecondsPassedHandler(object clockInstance.myEvent(1). Strings are immutable. A value type is directly stored in a memory location on the stack. using System.ReadLine(). Bool. //both functions will be run.Threading.TwoSecondsPassed += new Clock. } public static void Subscriber1(object clockInstance. //The clock publishes an event that others subscribe to public event TwoSecondsPassedHandler TwoSecondsPassed.Start(). 38.ReadLine().WriteLine(param1). Console. new TimeEventArgs(1)). 35. } } } Another example: using System.String 37.instanceSeconds). Console.TwoSecondsPassed += new Clock. instanceSeconds = seconds. byte.TwoSecondsPassedHandler(Subscriber1).TwoSecondsPassedHandler(Subscriber2). cl. 34. 37. public void Start() { while(true) { Thread.WriteLine("Subscriber2:" + time. 36. cl. string is an alias for what? System. char. ASCII. TimeEventArgs time) { Console. TimeEventArgs time) { Console.Sleep(2000). //Raise event TwoSecondsPassed(this.

768 to 32. 48. 45. 46. 41. equals. 43. 48. 51. 47. 41. Like a Point for example which contains variables x and y.446. concat. 47. trim. tolower. object o = i. Write some code to box and unbox a value type. 39. copy. default: goto case 1. 50. break.648 to 2.483. 40. What is boxing and unboxing? Converting a value type (stack->heap) to a reference type (heap->stack). It is usually best to use a struct to represent simple entities with a few variables. What is the default value for a bool? 50. 46.147.Bear}. toupper. What does new do in terms of objects? Initializes an object. } 44.615 42. 45.Any changes to that string are in fact copies. Write code for a case statement. false 49. case 2: x=2. compare. 43.073. // Boxing int i = 4. What is a heap and a stack? There are 2 kinds of heap – 1: a chunk of memory where data is stored and 2: a tree based data structure. When we talk about the heap and the stack we mean the first kind of heap. and vise-versa.551. sbyte -128 to 127. 44.744.767. how do == and != (not overridden) work? They check to see if the references both point to the same object.483. Name a few string properties. 51. switch (n) { case 1: x=1. Write code for an enumeration. byte 0 – 255.647. public enum animals {Dog=1. Set it equal to null. Describe 5 numeric value types ranges. How do you dereference an object? . 42. 49. What is a pointer? A pointer is a reference to a memory address.709. Typically each thread will have its own stack.147. ulong 0 to 18.Cat. break. The stack is a LIFO data structure that stores variables and flow control information. 39. In terms of references. insert. // Unboxing i = (int) o. 40. short -32. What is a struct? Unlike in C++ a struct is not a class – it is a value type with certain restrictions. int -2.

Can C# have global overflow checking? 54. Is comares an object to a type and returns a boolean. What is explicit vs. z = (short)(x + y). An example of when an explicit cast is needed is when a value may be truncated. Can assignment operators be overloaded directly? No 59. // Implicit short shrt = 400. public static int myMethodUnch() { int z = (short)(x + y). return z. E. 55.WriteLine(e. const short y = 32767. // Max short value 57. Is a struct stored on the heap or stack? Stack The following will not: const short x = 32767. // Returns -2 } 55.ToString()). 59. // Using a checked expression public static int myMethodCh() { int z = 0. 52. What is checked { } and unchecked { }? Yes By default C# does not check for overflow (unless using constants).g. } catch (System. to say avoid compile time errors with constanst overflow. 58. 54.Console. 58. try { z = checked((short)(x + y)). int intgr = shrt. Give examples of both of the above. // Returns -2 } . Then the cast will raise no overflow exception and z will be assigned –2. //z = (short)(x + y). return z. static short y = 32767. } return z.g. implicit conversion? When converting from a smaller numeric type into a larger one the cast is implicit. const short y = 32767. // Max short value 56. // Throws the exception OverflowException } This code will raise an exception. we can use checked to raise an exception. 56.OverflowException e) { System. // Explicit shrt = (short) intgr. if we remove unchecked as in: //z = checked((short)(x + y)). // Max short value 53. What do operators is and as do? as acts is like a cast but returns a null on conversion failure. unchecked can be used in the opposite way. E.: static short x = 32767. 53. Can a struct have methods? Yes public static int myMethodUnch() { int z = unchecked((short)(x + y)). the following will cause a compiler error: const short x = 32767.52. 57.

and conversion. public static bool operator == (TempleCompare x. 67.Write(x). 63. class TempleCompare { 65. What does operator order of precedence mean? Certain operators are evaluated before others. What is special about the declaration of relational operators? Relational operators must be declared in pairs. 63. x = 2. typeof obtains the System. E. } No . An operator declaration must include a public and static modifier. double x. Console. x = 2. What is the difference between the new operator and modifier? The new operator creates an instance of a class whereas the new modifier is used to declare a method with the same name as a method in one of the parent classes. 70. 68.Type object for a type and sizeof obtains the size of a type. can it have other modifiers? public int templeCompareID. 60. Write some code to overload an operator.g. What doe the stackalloc operator do? Allocate a block of memory on the stack (used in unsafe mode). Unary. Arithmetic: + Logical (boolean and bitwise): & String concatenation: + Increment.Write(++x). Brackets help to avoid confusion. Console. Returns 323 69. 64. Describe an operator from each of these categories: 62. 62. 64. 65. 69. count++. 61. Explain sizeof and typeof. 67.Write(x++).60. decrement: ++ Shift: >> Relational: == Assignment: = Member access: . public int templeValue. No 66.templeValue == y. Contrast ++count vs. What are the names of the three types of operators? 70.templeValue). 66. Indexing: [] Cast: () Conditional: ?: Delegate concatenation and removal: + Object creation: new Type information: as Overflow exception control: checked Indirection and Address: * 68. Can operator parameters be reference parameters? 61. binary. TempleCompare y) { return (x. Console. Some operators have temporal properties depending on their placement.

What are expression and declaration statements? • •   Expression – produces a value e. 72. TempleCompare y) { return !(x == y).g. 76. // try-catch-finally using System. } finally { Console. } } public class TCFClass { public static void Main () { try { throw new NullReferenceException(). 71. 77. new. typeof } Console. 76.g. 80.templeCompareID == t. What is an exception? A runtime error. 80. ?:. 77. What operators cannot be overloaded? =. Can break exit a finally block? 79. TempleCompare t = (templeCompare) o.WriteLine("finally block. . } public override bool Equals(object o) { // check types match if (o == null || GetType()!= o. sizeof. Can Continue exit a finally block? No if (n==1) Console.WriteLine("n=1").templeValue == t. 79.public static bool operator != (TempleCompare x."). ->.} 74. is. 78. 75. } catch { 71. Can C# have multiple catch blocks? Yes 78.". e). else if (n==2) Console. 73. No int n=4.} what is an empty statement list? {. } public override int GetHashCode() { return templeCompareID. What is a dangling else? .WriteLine("n>3").. else Console.GetType()) return false. Write some if… else if… code. blah = 0 Declaration – e. 75.templeCompareID) && (this. return (this. } catch(NullReferenceException e) { Console. int blah. 73. 74.s2.WriteLine("n=2"). A block contains a statement list {s1.").WriteLine("{0} exception 1.templeValue). Write some try…catch…finally code. } } 72.WriteLine("exception 2. else if (n==3) Console.WriteLine("n=3").

84. } 85. foreach (int i in arr) { if (i%2 == 0) x++.1) { location++.j=j+2) using System. 82.11 to that array and use a foreach to do something with those values. Write some code for a while loop. i++) Console. i <= 5. else 86.i = i. } .1. for (int i = 1.g. } else { return false. } public bool MoveNext() { if (location < i.contents = contents. public class Items : IEnumerable { private string[] contents. public Items(string[] contents) { this. Write some code for a for loop for (int i = 1.Length . n++.WriteLine(i).contents. } private class ItemsEnumerator : IEnumerator { private int location = -1. Console. 85.7.Write("Dangling Else") while(y < 5).i++ . int x. using System. 81. 84.if (n>0) if (n2>0) Console. Write some code for a custom collection class. int y = 0. else y++. } 82. 83. 81. 86. int[] arr = new int [] {0.WriteLine("Current value of n is {0}".2}.WriteLine(x). Is switch case sensitive? Yes int x = 0. while (n < 6) { Console. j = 2. return true. public ItemsEnumerator(Items i) { this. Write some code that declares an array on ints. 83.Collections. n). y = 0. 87. assigns the values: 0. do { x = y++. Can you increment multiple variables in a for loop control? Yes – e. private Items i.i <= 5 . 87. Write some code for do… while.8.1. int n = 1.5. } public IEnumerator GetEnumerator() { return new ItemsEnumerator(this).2.

5}. Can you resize an array at runtime? No 93. Write some code that uses an ArrayList.9}. 95.7.6.4. Can an ArrayList be ReadOnly? 91. 90. 92. {8.8}. Break terminates a loop or switch. 96. and goto. } Console. Write some code to implement a multidimensional array. What is the default index of an array? 0 Yes 97. 7}. How do you declare a constant? public const int c1 = 5. 94. .Collections that can resize itself.WriteLine(item).5. 88. 9}}. } // Declare the array of two elements: int[][] myArray = new int[2][]. 89. // Initialize the elements: myArray[0] = new int[5] {1.} } public void Reset() { location = -1. 1}. 98. Items items = new Items(myArray). 90. foreach (string item in items) { Console.ReadLine(). Does the size of an array need to be defined at compile time. } } } static void Main() { // Test string[] myArray = {"a". 96.contents[location]. What is an ArrayList? A data structure from System. 93. 97. No 94."c"}. } public object Current { get { return i. myArray[1] = new int[4] {2.] b = {{0. What is array rank? 98."b". 91. 3}. Write some code to implement a jagged array. Goto jumps to a labelled statement. } The dimension of the array. 92. Continue jumps to the next iteration of an enclosing iteration statement. 95. {2. 88. int[.3. {6. Describe Jump statements: break. {4. continue. 89.

100. 102. } } 105. list. namespace Console1 { class Class1 { static void Main(string[] args) { MyIndexableClass m = new MyIndexableClass(). Console. public string this [int i] { get { return myData[i]. 99.Add("Hello"). Console. name? 101.Add("World"). } } class MyIndexableClass { private string []myData = {"one". Can a property be a ref or out parameter? A property is not classified as a variable – it can’t be ref or out parameter.WriteLine(m[2]). Write some code to implement an indexer. 104.ReadLine(). Can properties have an access modifier? 105. Yes 106. } } //read-only static public static int ClassPr { get { return b. Can properties hide base class members of the same Yes 106. // instance public string InstancePr { get { return a. What happens if you make a property static? 99. 104. } set { myData[i] = value.WriteLine(m[1]).WriteLine(m[0]). Console. using System. list. } } } } They become class properties. 103.ArrayList list = new ArrayList(). What is an accessor? An accessor contains executable statements associated with getting or setting properties. } set { a = value. What is early and late binding? . 101. Can an interface have properties? Yes 107. Console. 102. 103. Write some code to declare and use properties. 107. 100."two"."three"}.

120. 109. What is polymorphism 115. Do local values get garbage collected? They die when they are pulled off the stack (go out of scope). 109. System. What is a namespace? 117. accessibility? 111. What is a nested class? 116. Can base constructors can be private? 119. How do you refer to a member in the base class? . 112. object is an alias for what? the new statement allocates memory for an object on the heap. The using statement defines a scope at the end of which an object will be disposed. What namespace would you use for reflection? Polymorphism is the ability to implement the same operation many times. 108. 112. A namespace declares a scope which is useful for organizing code and to distinguish one type from another. 111. 121. 114. System. When no objects reference the object it may be removed from the heap (this is a non deterministic process). 3. Each derived method implements the operation inherited from the base class in its own way. 121. Finalize is called just before the memory is released. 110.object instead of explicitly declaring a class (which is early binding). 2. 108. 116. Can nested classes use any of the 5 types of No 118.Reflection 115. What is reflection? 120. Reflection allows us to analyze an assembly’s metadata and it gives us a mechanism to do late binding. What is the using statement for? 114. Is object destruction deterministic? Yes 119. What does this do? Public Foo() : this(12. 0) Calls another constructor in the list A class declare within a class. Yes 113. 118.Object 1. 117. 0.Late binding is using System. Describe garbage collection (in simple terms). Garbage collection eliminates uneeded objects. 110. 113.

NameOfMethod(). What are the 2 global attributes. Public Extended : base()à this is called the constructor initializer. 133. 129. In terms of constructors. Does C# have “friendship”? 134. Transaction. No 123. 127. Can different assemblies share internal access? Attributes are declarative tags which can be used to mark certain entities (like methods for example). What keyword would you use for scope name clashes? 132.0 127. 129. 125. System. Can you have nested namespaces? 133. Can abstract methods override virtual methods? 131. 123. 136. Can you inherit from multiple interfaces? 135. 128. 134. Can you derive from a struct? Nothing 130. All classes derive from what? this 131. 125. Yes 132. What are attributes? 126.Object 124. Visual Designer Component Builder 135. Is constructor or destructor inheritance explicit or implicit? What does this mean? Constructor or destructor inheritance is explicit…. COM Interop. No 122. Yes 128. No 126. what is the difference between: public MyDerived() : base() an public MyDerived() in a child class? 122. 136. Why would you mark something as Serializable? . Does C# supports multiple inheritance? Yes 130. assembly and module. 124. Not before C# 2. Name 3 categories of predefined attributes.To refer to a member in the base class use:return base.

using System. Assembly – assembly Class – type Delegate . 140. 141. A thread has: // cs_attributes_retr. A thread is a the entity within a process that Windows schedules for execution. namespace ConsoleApplication4 { class Class1 { [STAThread] static void Main(string[] args) { ThreadClass tc1 = new ThreadClass(1). Write code to use threading and the lock keyword. etc. Spin off 141. public string GetName() { return name.). } } • • • • The contents of a set of CPU registers representing the state of the processor. Private storage called Thread Local Storage for use by subsystems.0.Threading. string name. List some custom attribute scopes and possible targets. OS. oT1. version = 1. and 1 for user mode.type.ReadLine().To show that the marked type can be serialized.Start(). 1 for the thread to use in kernel mode. AllowMultiple=true)] public class Author : Attribute { public Author(string name) { this. What is a thread? 137. Thread oT1 = new Thread(new ThreadStart(tc1. It indicates a field can be modified by an external entity (thread. Do you spin off or spawn a thread? 142. } public double version. using System. 138.ThreadMethod)). and DLLs. oT2. #if #else #elif #endif #define #undef #warning #error #line #region #endregion 139. 2 stacks.Start(). Threads sometimes have their own security context. A thread ID. What is the volatile keyword used for? 138.name = name.cs using System. Write code to define and use your own custom attribute. } 139. List some compiler directives? . Console. [AttributeUsage(AttributeTargets. ThreadClass tc2 = new ThreadClass(2). 143. return 143. (From MSDN) 137. 140.Struct.Class|AttributeTargets.ThreadMethod)). Thread oT2 = new Thread(new ThreadStart(tc2. run-time libraries. 142.

What mechanisms does C# have for the readers. What is IDLASM used for? A resource management. 149.) { lock(lockValue) { Console. Where are private assemblies stored? System. 145. 149. What is Monitor? 151. What does the assembly manifest contain? Monitor is a class that has various functions for thread synchronization. which can be dynamically loaded. 155. What is an assembly? Assemblies contain logical units of code in MSIL. Thread. version number. metadata. 150. What is an assembly identity? 151.ReaderWriterLock which has methods AcquireReaderLock.Threading. and optional public key to guarantee uniqueness. AcquireWriterLock. The GAC 154. public ThreadClass(int threadNumber) { this. } } } } } Assembly identity is name.. Use IDLASM to see assembly internals. 152. 148. synchronization.Sleep(1000). What is DLL hell? . What is a semaphore? 152. 144. 150. Where are shared assemblies stored? 147.WriteLine(threadNumber + " working"). What is Mutex? A Mutex object is used to guarantee only one thread can access a critical resource an any one time. } public void ThreadMethod() { for (. What is a DLL? A set of callable functions. 146. and locking tool. 147. problem? 146. 148. and usually a manifest. ReleaseReaderLock. public int threadNumber. 144. 145. writers 153.} class ThreadClass { private static object lockValue = "dummy".threadNumber = threadNumber. Assembly manifest lists all names of public types and resources and their locations in the assembly. 155. It disassembles into MSIL. Assemblies can be signed and the can dome in the form of a DLL or EXE. Same folder as exe 153. and ReleaseWriterLock 154. and optional culture.

StringBuilder Unsafe code bypasses type safety and memory management. Give examples of hex.Write("{0:F2}". Applicatioins using say these older DLLs expect some behaviour which is not present. From 166.Write("{0:X}". What does the fixed statement do? 165.Write.Text. 250). Console. Console.50 Console. Are value types are slower to pass as method parameters? Yes 158. Thread pools give us thread reuse. Describe the CLR security model. 161. à 25. currency.microsoft. In terms of assemblies. EventArgs e) +34. 159. What is unsafe code? 164. 25). à $2. 158.DLLs. 160.00 An app can be configured to use different versions of an assembly simultaneously. à FA Console. VBX or OCX files being unavailable or in the wrong versions. 164. Name and describe 5 different documentation tags. 156. /// /// /// /// /// /// /// /// /// /// 157.Write("{0:C}". 163. 160. what is side-by-side execution? Console. How would you read and write using the console? 166. 165. 163. and fixed point console 156.Page_Load(Object sender. 2. 162. Given part of a stack trace: aspnet. formatting. rather than creating a new thread every time. A thread pool is a means by which to control a number of threads simultaneously. How can you implement a mutable string? System.BadForm.WriteLine. Console. What is a thread pool? Prevents relocation of a variable by GC.com/msdnmag/issues/02/09/SecurityinNET/default. 157.5).debugging. <value></value> <example></example> <exception cref=""></exception> <include file='' path='[@name=""]'/> <param name="args"></param> <paramref name=""/> <permission cref=""></permission> <remarks> </remarks> <summary> /// <c></c> /// <code></code> /// <list type=""></list> /// <see cref=""/> /// <seealso cref=""/> /// </summary> 162. 161. What does the +34 mean? It is an actual offset (at the assembly language level) – not an offset into the IL instructions.aspx . 159.Readline http://msdn.

called code access security. 169. the CLR enforces security policy based on where code is coming from rather than who the user is. Describe some common design patterns. From 168. From What does marshalling mean? 168.” http://www.dictionary. and it helps call-site-specific compiler optimizations.com/Patterns/Patterns.” 167. • • • • • • •        170. What is inlining? http://www.“Unlike the old principal-based security. makes sense in today's environment because so much code is installed over the Internet and even a trusted user doesn't know when that code is safe. which is especially important for small and frequently called functions. camelCasing 171. 169. Singleton Structural Patterns Partial class definitions Nullable Types Anonymous methods :: operator Static classes static class members Adapter Bridge Match interfaces of different classes Separates an object’s interface from its implementation A tree structure of simple and composite objects Composite .aspx Creational Patterns From (Google web defintions) “In-line expansion or inlining for short is a compiler optimization which "expands" a function call site into the actual implementation of the function which is called. The packing process not only collects together values which may be stored in non-consecutive memory locations but also converts data of different types into a standard representation agreed with the recipient of the message.com/Patterns/Patterns.aspx “Design patterns are recurring solutions to software design problems you find again and again in real-world application development.” 172.” Abstract Factory Builder Creates an instance of several families of classes Separates object construction from its representation Creates an instance of several derived classes Factory Method Prototype A fully initialized instance to be copied or cloned A class of which only a single instance can exist 170.net/marshalling “The process of packing one or more items of data into a message buffer. 167. From 172. especially constant propagation. What are design patterns? PascalCasing.0. rather than each call transferring control to a common piece of code.dofactory. This model. Generics Iterators List the differences in C# 2. prior to transmitting that message buffer over a communication channel.dofactory. What’s the difference between camel and pascal casing? • • • • • •       Extern keyword Accessor accessibility Covariance and Contravariance Fixed size buffers Fixed assemblies #pragma warning 171. This reduces overhead associated with the function call. http://www.

an activity diagram also consists of activities. Object diagram: The object diagram is a special kind of class diagram. An object is an instance of a class. at a high level. The interactions are listed as numbered interactions that help to trace the sequence of the interactions. The primary elements are termed as "actors" and the processes are called "use cases. The relationship or association between the classes can be either an "is-a" or "has-a" relationship. actions. This diagram is by far most useful when a system is built and ready to be deployed.php/1553851 • “Use case diagram: The use case diagram is used to identify the primary elements and processes that form the system." The use case diagram shows which actors interact with each use case. The class diagram classifies the actors defined in the use case diagram into a set of interrelated classes. State diagram: A state diagram. The collaboration diagram helps to identify all the possible interactions that each object has with other objects.Decorator Façade Add responsibilities to objects dynamically • A single class that represents an entire subsystem A fine-grained instance used for efficient sharing Flyweight Proxy Class diagram: The class diagram is used to refine the use case diagram and define a detailed design of the system. used for? From 173. transitions. Component diagram: The component diagram represents the high-level parts that make up the system. Deployment diagram: The deployment diagram captures the configuration of the runtime elements of the application. Sequence diagram: A sequence diagram represents the interaction between different objects in the system. This means that the exact sequence of the interactions between the objects is represented step by step. The important aspect of a sequence diagram is that it is time-ordered. represents the different states that objects in the system undergo during their life cycle. In addition to this.” An object representing another object • Behavioral Patterns Chain of Resp. Different objects in the sequence diagram interact with each other by passing "messages". Objects in the system change states in response to events. as the name suggests. Collaboration diagram: A collaboration diagram groups together the interactions between different objects. Similar to a state diagram. what components form part of the system and how they are interrelated. a state diagram also captures the transition of the object's state from an initial state to a final state in response to events affecting the system. The object diagram captures the state of different classes in the system and their relationships or associations at a given point of time. Command Interpreter Iterator Mediator Memento Observer State A way of passing a request between a chain of objects • Encapsulate a command request as an object A way to include language elements in a program • • Sequentially access the elements of a collection Defines simplified communication between classes Capture and restore an object's internal state A way of notifying change to a number of classes • • Alter an object's behavior when its state changes Encapsulates an algorithm inside a class Defer the exact steps of an algorithm to a subclass Strategy Template Method Visitor • Defines a new operation to a class without change 173. This essentially means that an object represents the state of a class at a given point of time while the system is running. • • Describe the difference between a Thread and a Process? What is a Windows Service and how does its lifecycle differ from a "standard" EXE? .developer.NET Developers Ought To Know Everyone who writes code http://www. and guard conditions. Apart from this. initial and final states. each class may have certain "attributes" that uniquely identify the class. Each class in the class diagram may be capable of providing certain functionalities. This diagram depicts. Activity diagram: The process flows in the system are captured in the activity diagram. These functionalities provided by the class are termed "methods" of the class. What are the different diagrams in UML? What are they What Great . A component diagram depicts the components culled after the system has undergone the development or construction phase.com/design/article.

LoadFile be appropriate? What is an Asssembly Qualified Name? Is it a filename? How is it different? • What is FullTrust? Do GAC’ed assemblies have FullTrust? . • • • • Describe what an Interface is and how it’s different from a Class.• What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design? • • • • Is this valid? Assembly.Load("foo. Object-oriented and Aspectoriented programming. What is Reflection? What is the difference between XML Web Services using ASMX and . what is the difference between early-binding and late-binding? • Is using Assembly. What are PDBs? Where must they be located for debugging to work? What is cyclomatic complexity and why is it important? Write a standard lock() plus “double check” to create a critical section around a variable access.NET Remoting using SOAP? Senior Developers/Architects • • • What’s wrong with a line like this? DateTime.NET? When you’re running a component within ASP.Load a static reference or dynamic reference? When would using Assembly. 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 .Parse(myString).NET Developer • Describe the difference between Interface-oriented." Name at least 3 component containers that ship now with the Windows Server Family.LoadFrom or Assembly. • • • • • Are the type system represented by XmlSchema and the CLS isomorphic? Conceptually. • • • • • What is the difference between Finalize() and Dispose()? How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization? What is a PID? How is it useful when troubleshooting a system? How many processes can listen on a single TCP/IP port? What is the GAC? What problem does it solve? • • • 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 . what process is it running within on Windows XP? Windows 2000? Windows 2003? Mid-Level .dll").NET CLR manage object lifetime? What is non-deterministic finalization? • • • What is the difference between an EXE and a DLL? What is strong-typing versus weak-typing? Which is preferred? Why? • Corillian's product is a "Component Container.NET.

sealed.} } How is this construct useful? • • • • • • • Contrast the use of an abstract base class against an interface? What is the difference between a.dll What ports must be open for DCOM over a firewall? What is the purpose of Port • • Why are out parameters a bad idea in .GetType()? Explain what’s happening in the first constructor: public class c{ public c(string a) : this() {.0. and abstract. • What is a PostBack? .} and catch(Exception e){throw.}. Explain the importance and use of each component of this string: Foo.NET? • What is this? Can this be used within a static method? ASP.Equals(b) and a == b? In the context of a comparison. public c() {. What is boxing? Is string a value type or a reference type? • Describe how a browser-based Form POST becomes a Server-Side event like Button1_OnClick. What benefit do you get from using a Primary Interop Assembly (PIA)? By what mechanism does NUnit know what methods to test? What is the difference between: catch(Exception e){throw e. Version=2. override.} • What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not? • Does JITting occur per-assembly or per-method? How does this affect the working set? • • What is the difference between typeof(foo) and myFoo. protected.NET (UI) Developers Explain current thinking around IClonable. What is shadowing? Explain the use of virtual.Write and Trace. Culture=neutral. What are tenets of each? How does the XmlSerializer work? What ACL permissions does a process using it require? • • • Juxtapose the use of override with new.• What benefit does your code receive if you decorate it with attributes demanding specific Security permissions? • What is the significance of the "PropertySpecified" pattern used by the XmlSerializer? What problem does it attempt to solve? • • • What does this do? gacutil /l | find /i "Corillian" What does this do? sn -t foo. what is object identity versus object equivalence? How would one do a deep copy in .NET? Are they? Can attributes be placed on specific parameters to a method? Why is this useful? C# Component Developers 135? • • Contrast OOP and SOA.Bar. PublicKeyToken=593777ae2d274679d • • Why is catch(Exception) almost always a bad idea? What is the difference between Debug. private and internal.0.Write? When should each be used? • • • • Explain the differences between public.205.

Include elements from both namespace. VaryByHeader. What is HEAD? myXmlDocument.NET? Developers using XML • Is the [ThreadStatic] attribute useful in ASP. • What kinds of events can an HttpModule subscribe to? What influence can they have on an implementation? What can be done without recompiling the ASP. • • What is Web Gardening? How would using it affect a design? Given one ASP.NET? • What three Session State providers are available in ASP. • Give an example of how using an HttpHandler could simplify an existing design that serves Check Images from an .NET.ValidateInput()? What kind of data is passed via HTTP Headers? Juxtapose the HTTP verbs GET and POST. how many application objects does it have on a single proc box? A dual? A dual with Web Gardening enabled? How would this affect a design? • • How does VaryByCustom work? How would one implement ASP.NET? Are there side effects? Good or bad? • • • • What is the purpose of XML Namespaces? When is the DOM appropriate for use? When is it not? Are there size limitations? What is the WS-I Basic Profile and why is it important? Write a small XML document that uses a default namespace and a qualified (prefixed) namespace. • • • • Explain how cookies work. Explain the importance of HttpRequest.NET HTML output caching. • Describe the difference between pull-style parsers (XmlReader) and eventingreaders (Sax) . Give an example of Cookie abuse.NET application.aspx page.SelectNodes("//mynode"). • How does if-not-modified-since work? How can it be programmatically implemented with ASP.NET technologies is it used for? • Name and describe at least a half dozen HTTP Status Codes and what they express to the requesting client. caching outgoing versions of pages generated via all values of q= except where q=5 (as in http://localhost/page.NET between reqeusts? Does every HttpRequest get its own thread? Should you use Thread Local storage with ASP.• • What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState? What is the <machinekey> element and what two ASP.NET? Why is this almost always a bad idea? When is it a good idea? • Describe ways to present an arbitrary endpoint (URL) and route requests to that endpoint to ASP.NET Application? • • • • What is the one fundamental difference between Elements and Attributes? What is the difference between Well-Formed XML and Valid XML? How would you validate XML using .aspx?q=5)? • Are threads reused in ASP.NET 1.1? What are the pros and cons of each? Explain <@OutputCache%> and the usage of VaryByParam.

Int32 System. 4. 1. The compiler offers compile time checking for backward compatibility. 1. 4. 4. Classes that are both in the same assembly and derived from the declaring class. System. . d) Encapsulating a copy of a value type in an object. 4. and classes derived from the declaring class. 2. Correct answers are in green color.Array[2] myArray. 1) The C# keyword ‘int’ maps to which . int[. string s = “n Test string”.Int16 System.Xml support DTDs? How? Can any XML Schema be represented as an object graph? Vice versa? 6) What compiler switch creates an xml file from the xml comments in the files in an assembly? 1. 3. 8) What is a delegate? 2) Which of these string definitions will prevent escaping on backslashes in C#? 1.NET developer. . string s = “’n Test string”. 3. Does System." What does it meant to say “the canonical” form of XML? 4. The runtime checks to see that only one version of an assembly is on the machine at any one time. An inter-process message channel. Internal methods can be only be called using reflection. 2. An assembly designed to alter the appearance or ‘skin’ of an application. A reference to an object in a different process. An assembly containing localized resources for another assembly. 1. 2. Only methods that are in the same class as the method in question. 7) What is a satellite Assembly? 1. A strongly typed function pointer. 2. since as far as I know they might still be using this test for prospective employees. What are their similarities and differences? Which is preferred and why? c) Encapsulating a value type in an object. Any corrections and suggestions would be forwarded to the author. string s = #”n Test string”. /text /doc /xml /help • • C# developer interview questions A representative of a high-tech company in United Kingdom sent this in today noting that the list was used for interviewing a C# .• 4) If a method is marked as protected internal who can access it? What is the difference between XPathDocument and XmlDocument? Describe situations where one should be used over the other. 5) What is boxing? Why is the XML InfoSet specification different from the Xml DOM? What does the InfoSet attempt to solve? b) Encapsulating a copy of an object in a value type. A light weight thread or process that can call a single method. It doesn’t. 9) How does assembly versioning in . 3. 2. • Contrast DTDs versus XSDs. 4. 4. System. 3. 4. a) Encapsulating an object in a value type. 2. 3.NET type? 1. 3. 2.Int64 System. • • • What is the difference between an XML "Fragment" and an XML "Document. Any DLL file used by an EXE file. I won’t disclose the name of the company. Classes within the same assembly. int[2] myArray. 3.] myArray. A peripheral assembly designed to monitor permissions requests from an application.NET allows assemblies to specify the name AND the version of any assemblies they need to run. string s = @”n Test string”. int[][] myArray.NET prevent DLL Hell? 3) Which of these statements correctly declares a two-dimensional array in C#? 1. 3.Int128 2.

Sample code: // Namespace: using act = System. 13) In Object Oriented Programming. 4. Factory Abstract Factory Singleton Builder 2. Explain some features of interface in C#? Comparison of interface with class (interface vs class): • An interface cannot inherit from a class. 4. private A() { } static public A GetInstance() { if ( instance == null ) instance = new A(). // Equivalent to System. how would you describe encapsulation? 1. the version in the derived class is used. which attribute must adorn a test class in order for it to be picked up by the NUnit GUI? 1. The conversion of one type of object to another.Runtime. 4. 2. 12) Which of the following operations can you NOT perform on an ADO. • A class can inherit from multiple interfaces. } } 1. A DataSet can be synchronised with a RecordSet. Name two ways that you can prevent a class from being instantiated? A class cannot be instantiated if it is abstract or if it has a private constructor. The runtime resolution of method calls. // Class: using list = System. When a virtual method is called on a reference.Runtime. The exposition of data. public class A { static private A instance. • An interface can inherit from multiple interfaces.Remoting.Activation. TestAttribute TestClassAttribute TestFixtureAttribute NUnitTestClassAttribute 3. What’s the difference between override and new in C#? This is all to do with polymorphism. so they cannot be inherited. properties.10) Which “Gang of Four” design pattern is shown below? 1. A DataSet can be synchronised with the database.UrlAttribute obj What keyword must a derived class use to replace a non-virtual inherited method? new keyword is used to replace (not override) an inherited method with one of the same name. Note that a struct is implicitly sealed. 3.Activation. But an interface can contain only abstract methods. 4. A DataSet can be converted to XML. The separation of interface and implementation. or indexers • Can an abstract class have non-abstract methods? • An abstract class may contain both abstract and non-abstract methods. When a method of a base class is overridden in a derived class. A sealed class is used primarily when the class contains static members. For instance: public class Base { public virtual void SomeMethod() { } } public class Derived : Base . 3. • Interface members must be methods.UrlAttribute obj.ArrayList. 3. You can then use it anywhere you normally would have used that class or namespace. return instance. 11) In the NUnit test framework. … list l = new list(). events. 2. even if the calling code didn’t “know” that the object was an instance of the derived class. but only one class. You can infer the schema from a DataSet. // Creates an ArrayList act.NET DataSet? 1.Collections.Remoting. the actual type of the object that the reference refers to is used to decide which method implementation to use. 2. ________________vic What type of class cannot be inherited? A sealed class cannot be inherited. The using alias has a scope within the namespace you declare it in. How do I use an alias for a namespace or class in C#? Use the using directive to create an alias for a long namespace or class.

It is an error to declare a default (parameterless) constructor for a struct. Note that . it’s passed by value instead of as a reference. Because of this.0).{ public override void SomeMethod() { } } … Base b = new Derived(). Of these. classes are reference types and structs are value types. will end up calling Derived.NET 2. • There is no inheritance for structs as there is for classes. First of all. However. the fields will remain unassigned and the object cannot be used until all the fields are initialized. and it cannot be the base of a class. it gets created on the stack. Structs. when you instantiate a struct. Unlike classes. Which interface(s) must a class implement in order to support the foreach statement? Required interface for foreach statement: . Also. When you call the New operator on a class. What is the difference between indexers and properties in C#? Comparison Between Properties and Indexers Indexers are similar to properties. three can be used with classes: abstract. you can create objects that behave like the built-in types and enjoy their benefits as well. • Structs can declare constructors. This means that you cannot create an instance of the class directly. Just keep in mind that they’re created on the stack and that you’re not dealing with references to them but dealing directly with them. and it does that exactly as classes do. Any class derived from it must implement all of its abstract methods and accessors. Despite its name. Explain Abstract. By using structs. it gets created and the appropriate constructor is called. Whenever you have a need for a type that will be used often and is mostly just a piece of data. static Specifies that a class contains only static members (. however. Struct members cannot have initializers. b. A default constructor is always provided to initialize the struct members to their default values.NET does not permit a class to be both abstract and sealed.SomeMethod. an abstract class can possess non-abstract methods and properties. and Static Modifiers in C#? C# provides many modifiers for use with types and type members. sealed and static. structs can be instantiated without using the New operator. but they must take parameters. A struct can implement interfaces. If you do not use New.SomeMethod(). • When you create a struct object using the New operator. but there are important differences that you should be aware of. • Structs are simple to use and can prove to be useful at times. when passing a struct to a method. it will be allocated on the heap. You will be working directly with the struct instance. This will yield performance gains. all of the rules defined for property accessors apply to indexer accessors as well. structs might be a good option. sealed Specifies that a class cannot be inherited (used as a base class). A struct cannot inherit from another struct or class. A class must implement the IEnumerable and IEnumerator interfaces to support the foreach statement. What is the difference between struct and class in C#? Structs vs classes in C# Structs may seem similar to classes. you will not be dealing with references to an instance of a struct as you would with classes. Except for the differences shown in the following . inherit from the base class object. Sealed.SomeMethod if that overrides Base. abstract Indicates that a class is to be used only as a base class for other classes.