-3

I completed my Training in an MNC and in my project mapping interview they asked these questions ..i was not sure about them please ....please kindly help

1) how many datatypes are there in C# ? what are they?

2) What is a abstract constructor? what can be the situation or scenario where you can implement them?

thank u

Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167

1 Answers1

2

1. How many data types are there in C#?

Technically infinite, because any class/struct could be considered, a "data type".

I think what is potentially meant here is, how many primitive types are there, and what are they?

They are:

byte, sbyte, short, ushort, int, uint, long, ulong, float, double, decimal, string, char, bool

I think that pretty much covers it...there may be a few missing/additional. You might also consider things like DateTime, and BigInteger as data types. (although these are not primitive).

2. What is a abstract constructor? what can be the situation or scenario where you can implement them?

An abstract constructor is a constructor defined as part of an abstract class. The class cannot be constructed/instantiated because it is abstract, however the constructor can be called from derivatives of the abstract class. Therefore when you override/implement the abstract class (parent), your implementing class (child), can utilize/call the abstract constructor in the parent.

Matthew Layton
  • 39,871
  • 52
  • 185
  • 313