Vinod Sebastian – B.Tech, M.Com, PGCBM, PGCPM, PGDBIO

Hi I'm a Web Architect by Profession and an Artist by nature. I love empowering People, aligning to Processes and delivering Projects.

Advertisements




Parameter Passing

In C#, when calling a method or function, parameters can be passed in different ways depending on the requirements. Here are the common ways of passing parameters:

1. Pass by Value

Pass by value involves passing a copy of the parameter’s value to the method. Any changes made to the parameter within the method do not affect the original value outside the method.

2. Pass by Reference (ref)

Passing by reference allows the method to modify the actual value of the parameter. Changes made to the parameter within the method are reflected in the original value outside the method.

3. Pass as Out

Passing as out requires the parameter to be assigned within the method before returning. It is often used when a method needs to return multiple values.

4. Pass as Param

Passing as param allows passing any number of similar parameters to a method. This can be useful when working with variable-length argument lists.

Understanding the different ways of parameter passing in C# is essential for writing efficient and effective code.

Categories: C#, IT Notes

Tags: C#, Programming World

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x