Click here to Skip to main content
15,884,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible to pass DataGridView class object as argument to a method without a reference. When I do it without REF key word, still any change to argument inside called method results with change in DataGridView in caller method.
Posted

1 solution

You are sending DataGridview reference to the method so if you modified to argument in the caller method that will reflect in your called method. If you don't want to change the argument in caller method you need to create one copy of the DataGridView and you need to send new copy as argument.

Pass by Value in C# - Stack Overflow[^]

But here better to send what ever data you want instead of complete DataGridView.

Still if you want to send DataGridview as parameter you can finding cloning DataGridView here.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900