• +91 9723535972
  • info@interviewmaterial.com

CSharp Interview Questions and Answers

CSharp Interview Questions and Answers

Question - 21 : - Speaking of Boolean data types, what's different between C# and C/C++?

Answer - 21 : -   There's no conversion between 0 and false, as well as any other number and true, like in C/C++.

Question - 22 : - Can you declare a C++ type destructor in C# like ~MyClass()?

Answer - 22 : -   Yes, but what's the point, since it will call Finalize(), and Finalize() has no guarantees when the memory will be cleaned up,  plus, it introduces additional load on the garbage collector.

Question - 23 : - Can you create enumerated data types in C#?

Answer - 23 : - Yes.

Question - 24 : - What's different about switch statements in C#?

Answer - 24 : - No fall-throughs allowed.

Question - 25 : - Will finally block get executed if the exception had not occurred?

Answer - 25 : -   Yes.

Question - 26 : - What's the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?

Answer - 26 : -   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 {}.

Question - 27 : - Can multiple catch blocks be executed?

Answer - 27 : -   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.

Question - 28 : -
How do you generate documentation from the C# file commented properly with a command-line compiler?

Answer - 28 : - Compile it with a /doc switch.

Question - 29 : - What’s the implicit name of the parameter that gets passed into the class’ set method?

Answer - 29 : - Value, and its datatype depends on whatever variable we’re changing.

Question - 30 : - How do you inherit from a class in C#?

Answer - 30 : - Place a colon and then the name of the base class. Notice that it’s double colon in C++.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners