C Sharp Interview Questions and Answers - 1

Question: 1

Can you prevent your class from being inherited by another class?

Yes. The keyword “sealed” will prevent the class from being inherited.

Question: 2

What is value type?

A value type is a class whose state may be passed between a client and remote service as a method parameter or return value.

For example, an account class may have account number, account owner and amount field.

These information may be passed between client and server as a method deposit parameter and a return value of method account query.

Question: 3

What does the keyword “virtual” declare for a method or property?

The method or property can be overridden.

Question: 4

Is there an equivalent of exit () for quitting a C# .NET application?

Yes, you can use System.Environment.Exit (int exitCode) to exit the applications or Application.Exit() if it’s a Windows Forms app.

Question: 5

Is there regular expression (regex) support available to C# developers?

Yes, the .NET class libraries provide support for regular expressions.

Look at the System.Text.RegularExpressions namespace.

Related Questions