Home > Articles > Programming > C#

  • Print
  • + Share This
This chapter is from the book


Q. What does being statically typed mean?

A. C# is a statically typed language, so you must always inform the compiler of the data type for any variable you create. In return, the compiler guarantees that you can store only compatible data in that variable.

Q. Does C# have pointers?

A. C# does have pointer types, although they are not part of the core language. Pointers are available only in the context of unsafe code.

Q. Why is the unified type system in C# important?

A. By providing a unified type system, C# enables the value of any type to be treated as an object without unnecessary overhead.

Q. Are all the predefined types CLS-compliant?

A. No, the unsigned integer types and the sbyte type are not CLS-compliant. There are CLS-compliant types that can be used in place of these types, if necessary.

Q. Is a variable declared using var strongly typed?

A. Yes, a variable declared using var is still strongly typed because you let the compiler fill in the real type during compilation. var is not equivalent to the Visual Basic Variant type.

Q. What is the difference between a value type and a reference type?

A. Value types directly contain their data, whereas reference types contain a reference to their data.

Q. Can value types be null?

A. All value types are either nullable or non-nullable. A nullable value type can be either null or a value of its underlying non-nullable type. A non-nullable value type cannot be null.

Q. Why should you avoid boxing and unboxing operations when possible?

A. You should avoid boxing and unboxing operations when possible because they are expensive in terms of resources and overhead.

  • + Share This
  • 🔖 Save To Your Account