1/9
These flashcards cover key concepts related to parameter passing in C#, specifically focusing on the differences between value and reference semantics, modifiers, performance considerations, and best practices.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
Pass-by-Value
The called method receives a copy of the argument's data, and modifications affect only the local copy.
Pass-by-Reference
The called method receives an alias to the caller's variable storage location, allowing any mutation to change the caller's variable.
Value Type
A data type where the variable contains the data itself; for example, int or struct.
Reference Type
A data type where the variable contains a reference (pointer) to an object on the heap.
ref modifier
An explicit modifier that passes the variable by reference, allowing the method to read and write to the caller's variable.
out modifier
An explicit modifier used for output parameters that must be assigned within the method before it returns.
in modifier
A readonly reference modifier that allows passing by reference without permitting the method to modify the parameter.
Boxing
The process of wrapping a value type in a reference type, resulting in extra memory allocation.
Immutability
A programming practice where objects cannot be modified after they are created, leading to safer code.
Best Practice
Strategies and guidelines for developers to avoid common pitfalls, such as avoiding unsynchronized mutation in multi-threaded environments.