Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What's The Difference Between <c> And <code> Xml Documentation Tag?

Answer»

SINGLE LINE CODE EXAMPLE and multiple-line code example.

Single line code example and multiple-line code example.

2.

What's A Satellite Assembly?

Answer»

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.

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.

3.

What's A Multicast Delegate?

Answer»

It’s a delegate that POINTS to and EVENTUALLY fires off SEVERAL methods.

It’s a delegate that points to and eventually fires off several methods.

4.

What's The C# Equivalent Of C++ Catch (...), Which Was A Catch-all Statement For Any Possible Exception?

Answer»

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 {}.

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 {}.

5.

What's Class Sortedlist Underneath?

Answer»

A SORTED HASHTABLE.

A sorted HashTable.

6.

What Is The Difference Between Proc. Sent By Val And By Sub?

Answer»

BY VAL: changes will not be reflected BACK to the variable.
By REF: changes will be reflected back to that variable.( same as & SYMBOL in c, c++)

BY VAL: changes will not be reflected back to the variable.
By REF: changes will be reflected back to that variable.( same as & symbol in c, c++)

7.

Which Control Cannot Be Placed In Mdi?

Answer»

The CONTROLS that do not have EVENTS.

The controls that do not have events.

8.

Which Property Of The Textbox Cannot Be Changed At Runtime?

Answer»

LOCKED PROPERTY.

Locked Property.

9.

What Is The Maximum Size Of The Textbox?

Answer»

65536.

65536.

10.

Which Controls Do Not Have Events?

Answer»

TIMER CONTROL.

Timer control.

11.

How Can You Clean Up Objects Holding Resources From Within The Code?

Answer»

CALL the dispose METHOD from code for CLEAN up of objects.

Call the dispose method from code for clean up of objects.

12.

Describe Ways Of Cleaning Up Objects.

Answer»

There is a PERFECT tool provide by .net frameworks calls Garbage collector, where by mean of GC we can clean up the object and reclaim the memory. The namespace used is System.GC

the run time will maintain a service called as garbage collector. This service will take care of DEALLOCATING memory corresponding to objects. it works as a thread with least priority. when application demands for memory the runtime will take care of setting the high priority for the garbage collector, so that it will be called for EXECUTION and memory will be released. the programmer can make a CALL to garbage collector by using GC class in system name space.

There is a perfect tool provide by .net frameworks calls Garbage collector, where by mean of GC we can clean up the object and reclaim the memory. The namespace used is System.GC

the run time will maintain a service called as garbage collector. This service will take care of deallocating memory corresponding to objects. it works as a thread with least priority. when application demands for memory the runtime will take care of setting the high priority for the garbage collector, so that it will be called for execution and memory will be released. the programmer can make a call to garbage collector by using GC class in system name space.

13.

Explain Constructor.

Answer»

Constructor is a method in the CLASS which has the same name as the class (in VB.Net its NEW()). It initializes the MEMBER attributes WHENEVER an instance of the class is created.

Constructor is a method in the class which has the same name as the class (in VB.Net its New()). It initializes the member attributes whenever an instance of the class is created.

14.

What Are The Two Kinds Of Properties

Answer»

TWO TYPES of properties in .Net: GET and Set

Two types of properties in .Net: Get and Set

15.

Difference Between Value And Reference Type. What Are Value Types And Reference Types?

Answer»

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

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

16.

Difference Between Imperative And Interrogative Code.

Answer»

There are IMPERATIVE and interrogative functions. Imperative functions are the ONE which return a VALUE while the interrogative functions do not return a value.

There are imperative and interrogative functions. Imperative functions are the one which return a value while the interrogative functions do not return a value.

17.

Explain Manifest & Metadata.

Answer»

Manifest is metadata about assemblies. Metadata is machine-readable information about a RESOURCE, or “”data about data.” In .NET, metadata includes type definitions, version information, external assembly references, and other standardized information.

Manifest: Manifest describes assembly itself. Assembly Name, version number, culture, strong name, LIST of all files, Type references, and referenced assemblies.

Metadata: Metadata describes contents in an assembly classes, interfaces, enums, STRUCTS, etc., and their CONTAINING namespaces, the name of each type, its visibility/scope, its base class, the nterfaces it IMPLEMENTED, its methods and their scope, and each method’s parameters, type’s properties, and so on.

Manifest is metadata about assemblies. Metadata is machine-readable information about a resource, or “”data about data.” In .NET, metadata includes type definitions, version information, external assembly references, and other standardized information.

Manifest: Manifest describes assembly itself. Assembly Name, version number, culture, strong name, list of all files, Type references, and referenced assemblies.

Metadata: Metadata describes contents in an assembly classes, interfaces, enums, structs, etc., and their containing namespaces, the name of each type, its visibility/scope, its base class, the nterfaces it implemented, its methods and their scope, and each method’s parameters, type’s properties, and so on.

18.

Difference Between A Sub And A Function.

Answer»

A Sub does not return anything WHEREAS a Function returns something.

-A Sub PROCEDURE is a method will not return a value
-A sub procedure will be defined with a “Sub” keyword

Sub ShowName(ByVal myName As String)
Console.WriteLine(”My name is: ” & myName)
End Sub

-A function is a method that will return value(s).
-A function will be defined with a “Function” keyword

Function FindSum(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
DIM SUM As Integer = num1 + num2
Return sum
End Function

A Sub does not return anything whereas a Function returns something.

-A Sub Procedure is a method will not return a value
-A sub procedure will be defined with a “Sub” keyword

Sub ShowName(ByVal myName As String)
Console.WriteLine(”My name is: ” & myName)
End Sub

-A function is a method that will return value(s).
-A function will be defined with a “Function” keyword

Function FindSum(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
Dim sum As Integer = num1 + num2
Return sum
End Function

19.

Directcast(123.34,integer) - Should It Throw An Error? Why Or Why Not?

Answer»

It WOULD throw an InvalidCast exception as the runtime TYPE of 123.34 (double) DOESNT MATCH with INTEGER.

It would throw an InvalidCast exception as the runtime type of 123.34 (double) doesnt match with Integer.

20.

Ctype(123.34,integer) - Should It Throw An Error? Why Or Why Not?

Answer»

It WOULD work fine. As the RUNTIME TYPE of 123.34 would be double, and Double can be converted to Integer.

the CTYPE(123.34,integer) will work fine no errors.

It would work fine. As the runtime type of 123.34 would be double, and Double can be converted to Integer.

the ctype(123.34,integer) will work fine no errors.

21.

Why Does Dllimport Not Work For Me?

Answer»

All METHODS marked with the DllImport attribute MUST be marked as PUBLIC static EXTERN.

All methods marked with the DllImport attribute must be marked as public static extern.

22.

How Can I Access The Registry From C# Code?

Answer»

By using the REGISTRY and RegistryKey classes in Microsoft.Win32, you can easily access the registry. The following is a sample that reads a key and DISPLAYS its value:
using System;using Microsoft.Win32;
class regTest
{
public STATIC void Main(String[] ARGS)
{
RegistryKey regKey;
Object value;
regKey = Registry.LocalMachine;
regKey = regKey.OpenSubKey("HARDWAREDESCRIPTIONSystemCentralProcessor ");
value = regKey.GetValue("VendorIdentifier");
Console.WriteLine("The central processor of this MACHINE is: {0}.", value);
}
}

By using the Registry and RegistryKey classes in Microsoft.Win32, you can easily access the registry. The following is a sample that reads a key and displays its value:
using System;using Microsoft.Win32;
class regTest
{
public static void Main(String[] args)
{
RegistryKey regKey;
Object value;
regKey = Registry.LocalMachine;
regKey = regKey.OpenSubKey("HARDWAREDESCRIPTIONSystemCentralProcessor ");
value = regKey.GetValue("VendorIdentifier");
Console.WriteLine("The central processor of this machine is: {0}.", value);
}
}

23.

My Switch Statement Works Differently! Why?

Answer»

C# does not support an explicit fall through for case blocks. The following code is not legal and will not compile in C#:
switch(x)
{
case 0:
// do something
case 1:
// do something in common with 0
default:
// do something in common with
//0, 1 and everything ELSE
break;
}
To achieve the same effect in C#, the code must be modified as shown below (notice how the control flows are explicit):
CLASS Test
{
PUBLIC static void Main()
{
INT x = 3;
switch(x)
{
case 0:
// do something
goto case 1;
case 1:
// do something in common with 0
goto default;
default:
// do something in common with 0, 1, and anything else
break;
}
}
}

C# does not support an explicit fall through for case blocks. The following code is not legal and will not compile in C#:
switch(x)
{
case 0:
// do something
case 1:
// do something in common with 0
default:
// do something in common with
//0, 1 and everything else
break;
}
To achieve the same effect in C#, the code must be modified as shown below (notice how the control flows are explicit):
class Test
{
public static void Main()
{
int x = 3;
switch(x)
{
case 0:
// do something
goto case 1;
case 1:
// do something in common with 0
goto default;
default:
// do something in common with 0, 1, and anything else
break;
}
}
}

24.

How Do Destructors And Garbage Collection Work In C#?

Answer»

C# has finalizers (similar to destructors except that the RUNTIME doesn't guarantee they'll be called), and they are specified as follows:
class C
{
~C()
{
// your code
}
public static void Main() {}
}
CURRENTLY, they OVERRIDE object.Finalize(), which is called during the GC process.

C# has finalizers (similar to destructors except that the runtime doesn't guarantee they'll be called), and they are specified as follows:
class C
{
~C()
{
// your code
}
public static void Main() {}
}
Currently, they override object.Finalize(), which is called during the GC process.

25.

How Do I Create A Delegate/multicastdelegate?

Answer»

C# requires only a single parameter for delegates: the METHOD address. Unlike other languages, where the programmer MUST specify an object reference and the method to invoke, C# can infer both pieces of information by just specifying the method's name. For example, let's use System.Threading.ThreadStart: Foo MyFoo = NEW Foo(); ThreadStart del = new ThreadStart(MyFoo.Baz); This means that delegates can invoke STATIC class methods and instance methods with the exact same syntax!

C# requires only a single parameter for delegates: the method address. Unlike other languages, where the programmer must specify an object reference and the method to invoke, C# can infer both pieces of information by just specifying the method's name. For example, let's use System.Threading.ThreadStart: Foo MyFoo = new Foo(); ThreadStart del = new ThreadStart(MyFoo.Baz); This means that delegates can invoke static class methods and instance methods with the exact same syntax!

26.

Is There An Equivalent To The Instanceof Operator In Visual J++?

Answer»

C# has the is OPERATOR:
EXPR is TYPE

C# has the is operator:
expr is type

27.

How Can I Get The Ascii Code For A Character In C#?

Answer»

Casting the char to an int will give you the ASCII value: char c = 'f';
System.Console.WriteLine((int)c); or for a CHARACTER in a string:
System.Console.WriteLine((int)s[3]);
The BASE CLASS libraries also OFFER ways to do this with the Convert class or Encoding CLASSES if you need a particular encoding.

Casting the char to an int will give you the ASCII value: char c = 'f';
System.Console.WriteLine((int)c); or for a character in a string:
System.Console.WriteLine((int)s[3]);
The base class libraries also offer ways to do this with the Convert class or Encoding classes if you need a particular encoding.

28.

What Is The Difference Between The Debug Class And Trace Class?

Answer»

Documentation LOOKS the same. Use Debug class for debug BUILDS, use TRACE class for both debug and RELEASE builds.

Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.

29.

What Is The Difference Between A Struct And A Class In C#?

Answer»

From language spec:
The LIST of similarities between classes and structs is as follows. Longstructs can implement interfaces and can have the same kinds of members as classes. Structs DIFFER from classes in several important ways; HOWEVER, structs are value types rather than REFERENCE types, and inheritance is not supported for structs. Struct values are stored on the stack or in-line. Careful programmers can sometimes enhance performance through judicious use of structs. For example, the use of a struct rather than a class for a Point can make a large difference in the number of memory allocations performed at runtime. The program below creates and initializes an array of 100 points. With Point IMPLEMENTED as a class, 101 separate objects are instantiated-one for the array and one each for the 100 elements.

From language spec:
The list of similarities between classes and structs is as follows. Longstructs can implement interfaces and can have the same kinds of members as classes. Structs differ from classes in several important ways; however, structs are value types rather than reference types, and inheritance is not supported for structs. Struct values are stored on the stack or in-line. Careful programmers can sometimes enhance performance through judicious use of structs. For example, the use of a struct rather than a class for a Point can make a large difference in the number of memory allocations performed at runtime. The program below creates and initializes an array of 100 points. With Point implemented as a class, 101 separate objects are instantiated-one for the array and one each for the 100 elements.

30.

How Do I Convert A String To An Int In C#?

Answer»

Here's an example:
using System;
CLASS StringToInt
{
public static void MAIN()
{
STRING s = "105";
int x = Convert.ToInt32(s);
Console.WriteLine(x);
}
}

Here's an example:
using System;
class StringToInt
{
public static void Main()
{
String s = "105";
int x = Convert.ToInt32(s);
Console.WriteLine(x);
}
}

31.

Why Do I Get An Error (cs1006) When Trying To Declare A Method Without Specifying A Return Type?

Answer»

If you LEAVE off the RETURN type on a method declaration, the compiler thinks you are trying to declare a constructor. So if you are trying to declare a method that RETURNS nothing, use VOID. The following is an example: // This RESULTS in a CS1006 error public static staticMethod (mainStatic obj) // This will work as wanted public static void staticMethod (mainStatic obj)

If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a constructor. So if you are trying to declare a method that returns nothing, use void. The following is an example: // This results in a CS1006 error public static staticMethod (mainStatic obj) // This will work as wanted public static void staticMethod (mainStatic obj)

32.

How Can I Get Around Scope Problems In A Try/catch?

Answer»

If you try to INSTANTIATE the class inside the try, it'll be out of SCOPE when you try to access it from the catch block. A WAY to get around this is to do the following:
Connection conn = null;
try
{
conn = new Connection();
conn.Open();
}
FINALLY
{
if (conn != null) conn.Close();
}
By setting it to null before the try block, you avoid getting the CS0165 error (Use of possibly unassigned local VARIABLE 'conn').

If you try to instantiate the class inside the try, it'll be out of scope when you try to access it from the catch block. A way to get around this is to do the following:
Connection conn = null;
try
{
conn = new Connection();
conn.Open();
}
finally
{
if (conn != null) conn.Close();
}
By setting it to null before the try block, you avoid getting the CS0165 error (Use of possibly unassigned local variable 'conn').

33.

How Do I Get Deterministic Finalization In C#?

Answer»

In a garbage collected environment, it's impossible to GET true determinism. However, a design pattern that we recommend is implementing IDisposable on any CLASS that contains a critical resource. Whenever this class is consumed, it MAY be placed in a using STATEMENT, as shown in the following example:
using(FileStream myFile = File.Open(@"c:temptest.txt", FileMode.Open))
{
int fileOffset = 0;
while(fileOffset < myFile.Length)
{
Console.Write((char)myFile.ReadByte());
fileOffset++;
}
}
When myFile leaves the lexical scope of the using, its dispose method will be CALLED.

In a garbage collected environment, it's impossible to get true determinism. However, a design pattern that we recommend is implementing IDisposable on any class that contains a critical resource. Whenever this class is consumed, it may be placed in a using statement, as shown in the following example:
using(FileStream myFile = File.Open(@"c:temptest.txt", FileMode.Open))
{
int fileOffset = 0;
while(fileOffset < myFile.Length)
{
Console.Write((char)myFile.ReadByte());
fileOffset++;
}
}
When myFile leaves the lexical scope of the using, its dispose method will be called.

34.

Describe The Accessibility Modifier Protected Internal?

Answer»

It is AVAILABLE to DERIVED CLASSES and classes within the same Assembly (and naturally from the BASE CLASS it is declared in).

It is available to derived classes and classes within the same Assembly (and naturally from the base class it is declared in).

35.

Why Does My Windows Application Pop Up A Console Window Every Time I Run It?

Answer»

Make sure that the target type set in the PROJECT PROPERTIES setting is set to Windows Application, and not CONSOLE Application. If you're using the command line, compile with /target:winexe &AMP; not target:exe.

Make sure that the target type set in the project properties setting is set to Windows Application, and not Console Application. If you're using the command line, compile with /target:winexe & not target:exe.

36.

Can You Declare The Override Method Static While The Original Method Is Non-static?

Answer»

No, you cannot, the signature of the virtual METHOD must REMAIN the same, only the keyword virtual is CHANGED to keyword override.

No, you cannot, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.

37.

Does C# Support C Type Macros?

Answer»

No. C# does not have macros. Keep in MIND that what some of the predefined C macros (for example, __LINE__ and __FILE__) give you can also be found in .NET classes LIKE System.Diagnostics (for example, StackTrace and StackFrame), but they'll only work on debug builds.

No. C# does not have macros. Keep in mind that what some of the predefined C macros (for example, __LINE__ and __FILE__) give you can also be found in .NET classes like System.Diagnostics (for example, StackTrace and StackFrame), but they'll only work on debug builds.

38.

Does C# Support Parameterized Properties?

Answer»

No. C# does, however, support the concept of an indexer from language spec. An indexer is a member that enables an OBJECT to be indexed in the same way as an array. Whereas properties ENABLE field-like access, indexers enable array-like access. As an example, consider the Stack class presented earlier. The designer of this class may want to EXPOSE array-like access so that it is possible to inspect or alter the items on the stack without performing unnecessary Push and Pop OPERATIONS. That is, Stack is implemented as a linked list, but it also provides the convenience of array access.

Indexer declarations are similar to property declarations, with the main differences being that indexers are nameless (the name used in the declaration is this, since this is being indexed) and that indexers include indexing parameters. The indexing parameters are provided between square BRACKETS.

No. C# does, however, support the concept of an indexer from language spec. An indexer is a member that enables an object to be indexed in the same way as an array. Whereas properties enable field-like access, indexers enable array-like access. As an example, consider the Stack class presented earlier. The designer of this class may want to expose array-like access so that it is possible to inspect or alter the items on the stack without performing unnecessary Push and Pop operations. That is, Stack is implemented as a linked list, but it also provides the convenience of array access.

Indexer declarations are similar to property declarations, with the main differences being that indexers are nameless (the name used in the declaration is this, since this is being indexed) and that indexers include indexing parameters. The indexing parameters are provided between square brackets.

39.

Does C# Support Templates?

Answer»

No. However, there are PLANS for C# to support a type of template KNOWN as a GENERIC. These generic types have similar syntax but are instantiated at RUN time as OPPOSED to compile time. You can read more about them here.

No. However, there are plans for C# to support a type of template known as a generic. These generic types have similar syntax but are instantiated at run time as opposed to compile time. You can read more about them here.

40.

Does C# Support #define For Defining Global Constants?

Answer»

No. If you want to get something that WORKS like the FOLLOWING C CODE:
#DEFINE A 1
use the following C# code: class MyConstants
{
public const int A = 1;
}
Then you use MyConstants.A where you would otherwise use the A macro.
Using MyConstants.A has the same generated code as using the literal 1.

No. If you want to get something that works like the following C code:
#define A 1
use the following C# code: class MyConstants
{
public const int A = 1;
}
Then you use MyConstants.A where you would otherwise use the A macro.
Using MyConstants.A has the same generated code as using the literal 1.

41.

Is It Possible To Have A Static Indexer In C#?

Answer»

No. STATIC INDEXERS are not ALLOWED in C#.

No. Static indexers are not allowed in C#.

42.

Can I Define A Type That Is An Alias Of Another Type (like Typedef In C++)?

Answer»

Not exactly. You can create an alias within a single file with the "USING" directive: using SYSTEM; using Integer = System.Int32; // alias
But you can't create a true alias, one that extends BEYOND the file in which it is declared. Refer to the C# spec for more info on the 'using' STATEMENT's scope.

Not exactly. You can create an alias within a single file with the "using" directive: using System; using Integer = System.Int32; // alias
But you can't create a true alias, one that extends beyond the file in which it is declared. Refer to the C# spec for more info on the 'using' statement's scope.

43.

How Do I Port "synchronized" Functions From Visual J++ To C#?

Answer»

Original Visual J++ CODE: public SYNCHRONIZED void Run()
{
// function body
}
PORTED C# code: class C
{
public void Run()
{
lock(this)
{
// function body
}
}
public STATIC void Main() {}
}

Original Visual J++ code: public synchronized void Run()
{
// function body
}
Ported C# code: class C
{
public void Run()
{
lock(this)
{
// function body
}
}
public static void Main() {}
}

44.

What Is The Difference Between // Comments, /* */ Comments And /// Comments?

Answer»

Single-line, multi-line and XML DOCUMENTATION COMMENTS.

Single-line, multi-line and XML documentation comments.

45.

Is There Any Sample C# Code For Simple Threading?

Answer»

Some sample code follows: using System;
using System.Threading;
CLASS ThreadTest
{
public void runme()
{
Console.WriteLine("Runme CALLED");
}
public static void MAIN(String[] args)
{
ThreadTest b = new ThreadTest();
THREAD t = new Thread(new ThreadStart(b.runme));
t.Start();
}
}

Some sample code follows: using System;
using System.Threading;
class ThreadTest
{
public void runme()
{
Console.WriteLine("Runme Called");
}
public static void Main(String[] args)
{
ThreadTest b = new ThreadTest();
Thread t = new Thread(new ThreadStart(b.runme));
t.Start();
}
}

46.

Why Do I Get A Security Exception When I Try To Run My C# App?

Answer»

Some security exceptions are thrown if you are working on a network SHARE. There are some parts of the frameworks that will not run if being run off a share (ROAMING profile, mapped drives, etc.). To see if this is what's happening, just MOVE the executable over to your local drive and see if it runs without the exceptions. One of the common exceptions thrown under these conditions is System.Security.SecurityException.

To get around this, you can change your security POLICY for the intranet zone, code group 1.2, (the zone that running off shared folders falls into) by using the caspol.exe tool.

Some security exceptions are thrown if you are working on a network share. There are some parts of the frameworks that will not run if being run off a share (roaming profile, mapped drives, etc.). To see if this is what's happening, just move the executable over to your local drive and see if it runs without the exceptions. One of the common exceptions thrown under these conditions is System.Security.SecurityException.

To get around this, you can change your security policy for the intranet zone, code group 1.2, (the zone that running off shared folders falls into) by using the caspol.exe tool.

47.

Does Console.writeline() Stop Printing When It Reaches A Null Character Within A String?

Answer»

STRINGS are not null terminated in the runtime, so embedded nulls are allowed. Console.WriteLine() and all similar METHODS continue until the END of the STRING.

Strings are not null terminated in the runtime, so embedded nulls are allowed. Console.WriteLine() and all similar methods continue until the end of the string.

48.

From A Versioning Perspective, What Are The Drawbacks Of Extending An Interface As Opposed To Extending A Class?

Answer»

With regard to VERSIONING, interfaces are less flexible than classes. With a class, you can SHIP version 1 and then, in version 2, decide to add another method. As long as the method is not abstract (i.e., as long as you provide a default implementation of the method), any EXISTING derived classes continue to FUNCTION with no changes. Because interfaces do not support implementation inheritance, this same pattern does not hold for interfaces. Adding a method to an interface is like adding an abstract method to a base class--any class that implements the interface will break, because the class doesn't implement the new interface method.

With regard to versioning, interfaces are less flexible than classes. With a class, you can ship version 1 and then, in version 2, decide to add another method. As long as the method is not abstract (i.e., as long as you provide a default implementation of the method), any existing derived classes continue to function with no changes. Because interfaces do not support implementation inheritance, this same pattern does not hold for interfaces. Adding a method to an interface is like adding an abstract method to a base class--any class that implements the interface will break, because the class doesn't implement the new interface method.

49.

What Is The Difference Between Const And Static Read-only?

Answer»

The difference is that static read-only can be MODIFIED by the containing class, but const can never be modified and MUST be initialized to a COMPILE time constant. To expand on the static read-only CASE a bit, the containing class can only modify it: -- in the variable declaration (through a variable initializer).
-- in the static constructor (instance constructors if it's not static).

The difference is that static read-only can be modified by the containing class, but const can never be modified and must be initialized to a compile time constant. To expand on the static read-only case a bit, the containing class can only modify it: -- in the variable declaration (through a variable initializer).
-- in the static constructor (instance constructors if it's not static).

50.

Is There A Way Of Specifying Which Block Or Loop To Break Out Of When Working With Nested Loops?

Answer»

The EASIEST way is to use goto:
using System;
CLASS BreakExample
{
public static void Main(String[] args)
{
for(int i=0; i<3; i++)
{
Console.WriteLine("Pass {0}: ", i);
for( int j=0 ; j<100 ; j++ )
{
if ( j == 10) goto DONE;
Console.WriteLine("{0} ", j);
}
Console.WriteLine("This will not print");
}
done:
Console.WriteLine("LOOPS complete.");
}
}

The easiest way is to use goto:
using System;
class BreakExample
{
public static void Main(String[] args)
{
for(int i=0; i<3; i++)
{
Console.WriteLine("Pass {0}: ", i);
for( int j=0 ; j<100 ; j++ )
{
if ( j == 10) goto done;
Console.WriteLine("{0} ", j);
}
Console.WriteLine("This will not print");
}
done:
Console.WriteLine("Loops complete.");
}
}