Logo 
Search:

c programming Interview FAQs

Submit Interview FAQ
No Records Found!!!
Go Ahead and Post your Interview FAQ
Home » Interview FAQs » c programmingRSS Feeds
C#
Comments: 0

Can I get the name of a type at runtime?

Yes, use the GetType method of the object class (which all types inherit from). For example:

using System;

class CTest
{
class CApp
{
public static void Main()
{
long ...
Posted By:Bonifaco Garcia      Posted On: Nov 18

C#
Comments: 0

What is the difference between typeof and GetType()?

Apart from the obvious (i.e. typeof operates on a type whereas GetType operates on an object), the main thing to watch out for is that GetType returns the underlying type of the object, which may not be the same as the type of the reference to the ob...
Posted By:Estella Mitchell      Posted On: Nov 25

C#
Comments: 0

Does the System.Exception class have any cool features?

Yes - the feature which stands out is the StackTrace property. This provides a call stack which records where the exception was thrown from. For example, the following code:

using System;

class CApp
{
public static void...
Posted By:Ray Lawrence      Posted On: Nov 25

C#
Comments: 0

When should I throw an exception?

This is the subject of some debate, and is partly a matter of taste. However, it is accepted by most that exceptions should be thrown only when an 'unexpected' error occurs. How do you decide if an error is expected or unexpected? This is a judgement...
Posted By:Chad Bradley      Posted On: Oct 07

C#
Comments: 0

Should I make my destructor virtual?

A C# destructor is really just an override of the System.Object Finalize method, and so is virtual by definition.
Posted By:Douglas Sullivan      Posted On: Sep 24

C#
Comments: 0

Can I use exceptions in C#?

Yes, in fact exceptions are the recommended error-handling mechanism in C# (and in .NET in general). Most of the .NET framework classes use exceptions to signal errors.
Posted By:Cambria Lopez      Posted On: Mar 02

C#
Comments: 0

Can I get the name of a type at runtime?

Yes, use the GetType method of the object class (which all types inherit from). For example:

using System;

class CTest
{
class CApp
{
public static void Main()
{
long ...
Posted By:Bonifaco Garcia      Posted On: Nov 18

C#
Comments: 0

What is the difference between typeof and GetType()?

Apart from the obvious (i.e. typeof operates on a type whereas GetType operates on an object), the main thing to watch out for is that GetType returns the underlying type of the object, which may not be the same as the type of the reference to the ob...
Posted By:Estella Mitchell      Posted On: Nov 25

C#
Comments: 0

Does the System.Exception class have any cool features?

Yes - the feature which stands out is the StackTrace property. This provides a call stack which records where the exception was thrown from. For example, the following code:

using System;

class CApp
{
public static void...
Posted By:Ray Lawrence      Posted On: Nov 25

C#
Comments: 0

When should I throw an exception?

This is the subject of some debate, and is partly a matter of taste. However, it is accepted by most that exceptions should be thrown only when an 'unexpected' error occurs. How do you decide if an error is expected or unexpected? This is a judgement...
Posted By:Chad Bradley      Posted On: Oct 07

C#
Comments: 0

Should I make my destructor virtual?

A C# destructor is really just an override of the System.Object Finalize method, and so is virtual by definition.
Posted By:Douglas Sullivan      Posted On: Sep 24

C#
Comments: 0

Can I use exceptions in C#?

Yes, in fact exceptions are the recommended error-handling mechanism in C# (and in .NET in general). Most of the .NET framework classes use exceptions to signal errors.
Posted By:Cambria Lopez      Posted On: Mar 02

  40  41  42  43  44  45  46  47  48  49  50