Skip to main content

What is the difference between pass-by-value and pass-by-reference?

Senior C#
Quick Answer Pass-by-value sends a copy รขโ‚ฌโ€ the method works on its own copy, original unchanged. Pass-by-reference (ref/out) sends the memory address รขโ‚ฌโ€ the method modifies the original variable. Value types default to pass-by-value; reference types pass the reference by value (the object itself is shared).

Answer

Pass-by-value: Copies the value; modifications do not affect the original.

Pass-by-reference: Passes the memory reference; modifications affect the original variable.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice