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

What types of object can I throw as exceptions?

Only instances of the System.Exception classes, or classes derived from System.Exception. This is in sharp contrast with C++ where instances of almost any type can be thrown.
Posted By:Topaz Ramirez      Posted On: Dec 14

C#
Comments: 0

Can I define my own exceptions?

Yes, just derive your exception class from System.Exception.

Note that if you want your exception to cross remoting boundaries you'll need to do some extra work - see www.thinktecture.com/.../CustomExceptions.html for details.
Posted By:Angie Bennett      Posted On: Mar 26

C#
Comments: 0

If C# destructors are so different to C++ destructors, why did MS use the same syntax?

Presumably they wanted C++ programmers to feel at home. I think they made a mistake.
Posted By:Willard Washington      Posted On: Nov 21

C#
Comments: 0

Are all methods virtual in C#?

No. Like C++, methods are non-virtual by default, but can be marked as virtual.
Posted By:Emily Brown      Posted On: Nov 25

C#
Comments: 0

How do I declare a pure virtual function in C#?

Use the abstract modifier on the method. The class must also be marked as abstract. Note that abstract methods cannot have an implementation (unlike pure virtual C++ methods).
Posted By:Jarrod Williams      Posted On: Jan 01

C#
Comments: 0

Can I call a virtual method from a constructor/destructor?

Yes, but it's generally not a good idea. The mechanics of object construction in .NET are quite different from C++, and this affects virtual method calls in constructors.

C++ constructs objects from base to derived, so when the base constructor is...
Posted By:Evelyn Hughes      Posted On: Sep 08

C#
Comments: 0

What types of object can I throw as exceptions?

Only instances of the System.Exception classes, or classes derived from System.Exception. This is in sharp contrast with C++ where instances of almost any type can be thrown.
Posted By:Topaz Ramirez      Posted On: Dec 14

C#
Comments: 0

Can I define my own exceptions?

Yes, just derive your exception class from System.Exception.

Note that if you want your exception to cross remoting boundaries you'll need to do some extra work - see www.thinktecture.com/.../CustomExceptions.html for details.
Posted By:Angie Bennett      Posted On: Mar 26

C#
Comments: 0

If C# destructors are so different to C++ destructors, why did MS use the same syntax?

Presumably they wanted C++ programmers to feel at home. I think they made a mistake.
Posted By:Willard Washington      Posted On: Nov 21

C#
Comments: 0

Are all methods virtual in C#?

No. Like C++, methods are non-virtual by default, but can be marked as virtual.
Posted By:Emily Brown      Posted On: Nov 25

C#
Comments: 0

How do I declare a pure virtual function in C#?

Use the abstract modifier on the method. The class must also be marked as abstract. Note that abstract methods cannot have an implementation (unlike pure virtual C++ methods).
Posted By:Jarrod Williams      Posted On: Jan 01

C#
Comments: 0

Can I call a virtual method from a constructor/destructor?

Yes, but it's generally not a good idea. The mechanics of object construction in .NET are quite different from C++, and this affects virtual method calls in constructors.

C++ constructs objects from base to derived, so when the base constructor is...
Posted By:Evelyn Hughes      Posted On: Sep 08

  41  42  43  44  45  46  47  48  49  50  51