C# Flashcards
Late and early binding
Early binding Or Compile time Or static binding: Assigning of object to type reference happens at compile time.
Late binding Or Run time Or Dynamic binding: Assigning of object to type reference happens at run time.
Early binding is efficient while late binding provides flexibility to programmers.
Early binding is best. Because any errors can be resolved at compile time. Late binding is at Run Time
All .Net code have to be cls compliant
Not required. If you want your code to be CLS complaint use the annotation CLScompliant(true)
Answered by: Ravi Kumar on: Dec 3rd, 2011
False All .Net code need not be CLS compliant if you are going to write all modules using single .Net language. However, if you are going to use different .Net language for different modules then you…
Explain what are object oriented language and object based language
Any langauge based on encapsulation concpet and operations with the objects are called as Object Based language. Exmaple : VB is a Object based and not an Object oriented
Any langauge based on encapsulation concept and operations with the objects and also dealing with the inheritance and polymorphism are called as Object Oriented language. Exmaple : C++,C#
Why strings are immutable?
makes it thread safe and
thus imporves performance.
1) In VB6.0 and c++ strings are simple array of bytes, but in .Net it is class System.String and is immutable.
2) A string is a sequential collection of Unicode characters, which usually is used to represent text. A String, on the other hand, is a .NET Framework class (System.String) that represents a Unicode string with a sequential collection of System.Char structure.
String is of reference type which holds an array of char.
string s = “abc”;
internally creates an array of char similar to one below
char[] s = new char[] {‘a’,’b’,’c’};
Arrays are created with definite length and it cannot be dynamically increased.
This is the reason behind immutability in string.
Can you store multiple data types in System.Array?
No
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The first one performs a deep copy of the array, the second one is shallow.
What’s the .NET datatype that allows the retrieval of data by a unique key?
HashTable
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 System.Exception. You can also omit the parameter data type in this case and just write catch {}.
Can multiple catch blocks be executed?
No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.
Why is it a bad idea to throw your own exceptions?
Well, if at that point you know that an error has occurred, 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.
What’s a delegate?
A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.
What’s a multicast delegate?
It’s a delegate that points to and eventually fires off several methods.
How’s 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’s 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, System.Resources.
What’s the difference between // comments, /* */ comments and /// comments?
Single-line, multi-line and XML documentation comments.
How do you generate documentation from the C# file commented properly with a command-line compiler?
Compile it with a /doc switch.
What’s the difference between and <code> XML documentation tag?</code>
Single line code example and multiple-line code example.
Is XML case-sensitive?
Yes, so and are different elements.
What does assert() 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.
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 and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing 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.