Difference between value and reference type. what are value types and reference types?
Value type – bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type – class, delegate, interface, object, string
Reference types are stored in the Heap
What are the two kinds of [...]
ctype(123.34,integer) – should it throw an error? Why or why not?
Answer1
It would work fine. As the runtime type of 123.34 would be double, and Double can be converted to Integer.
Answer2
the ctype(123.34,integer) will work fine no errors
directcast(123.34,integer) – should it throw an error? Why or why not?
It would throw an InvalidCast exception as the runtime type [...]
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 [...]
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 [...]
How can I create a process that is running a supplied native executable (e.g., cmd.exe)?
The following code should run the executable and wait for it to exit before
continuing: using System;
using System.Diagnostics;
public class ProcessTest {
public static void Main(string[] args) {
Process p = Process.Start(args[0]);
p.WaitForExit();
Console.WriteLine(args[0] + " exited.");
}
}
Remember to add a reference to System.Diagnostics.dll when you compile.
What is [...]
How do I create a multi language, multi file assembly?
Unfortunately, this is currently not supported in the IDE. To do this from the command line, you must compile your projects into netmodules (/target:module on the C# compiler), and then use the command line tool al.exe (alink) to link these netmodules together.
C# provides a default constructor [...]
Is there regular expression (regex) support available to C# developers?
Yes. The .NET class libraries provide support for regular expressions. Look at the documentation for the System.Text.RegularExpressions namespace.
Is there a way to force garbage collection?
Yes. Set all references to null and then call System.GC.Collect(). If you need to have some objects destructed, and System.GC.Collect() doesn’t seem [...]
So let’s say I have an application that uses MyApp.dll assembly, version 1.0.0.0. There is a security bug in that assembly, and I publish the patch, issuing it under name MyApp.dll 1.1.0.0. How do I tell the client applications that are already installed to start using this new MyApp.dll?
Use publisher policy. To configure a publisher [...]
How do you mark a method obsolete?
[Obsolete] public int Foo() {…}
or
[Obsolete(\"This is a message describing why this method is obsolete\")] public int Foo() {…}
Note: The O in Obsolete is always capitalized.
How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#?
You want the lock statement, which is the same as Monitor Enter/Exit:
lock(obj) { // code [...]
What’s C# ?
C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection.
Is it possible to inline assembly or IL in C# code?
- No.
Is it possible to have different access modifiers on the get/set methods [...]