What is the difference between int and nullable int?
An int cannot represent null. int? is shorthand for Nullable<int> and can represent either an integer or no value.
The question library
Explore practical questions, clear explanations, and code examples across developer technologies.
Showing 1021–1032 of 3610 questions
An int cannot represent null. int? is shorthand for Nullable<int> and can represent either an integer or no value.
Properties expose controlled access to state using get and set accessors. Auto-properties let the compiler generate backing storage.
Access modifiers control where types and members can be accessed. Common modifiers are public, private, protected, internal, protected internal, private pr
A constructor initializes a new instance. It has the class name and no return type. C# also supports static constructors and primary constructors in suppor
Overloading defines multiple methods with the same name but different parameter signatures. Return type alone cannot distinguish overloads.
ref passes a variable by reference and requires it to be assigned before the call. out requires the method to assign it. in passes by readonly reference an
An enum defines a set of named constants backed by an integral type. It makes code more readable than unexplained numeric values.
A struct is a value type, suitable for small values with value semantics. Structs can have methods and properties. Prefer immutable structs for predictable
Records are designed for data-centric types and provide value-based equality. Record classes are reference types; record structs are value types.
String interpolation embeds expressions inside a string using a dollar sign and braces.
A string cannot be changed after creation. Operations that appear to modify a string produce another string. Immutability simplifies sharing and hashing.
An array stores a fixed-size sequence of elements of the same type and uses zero-based indexing.