We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
So I was wondering if it's possible to set a variable in a helper method for example:
public static void SetX(this Point a, int val) { a = new Point(val, a.Y); // Will `a` change in the place where this function is called from? }
If this is not possible, can you recommend an alternative solution?
The text was updated successfully, but these errors were encountered:
Just mark the Point parameter to be passed by ref.
Point
ref
Side note: you should follow standard conventions and name your methods in PascalCase.
Sorry, something went wrong.
@Joe4evr
Dumb question: is that possible for extension methods? I've never tried on the assumption it isn't possible.
@marksmeltzer
Yup, it was added in C# 7.2, although only for structs.
Here's an example of it in action.
Just mark the Point parameter to be passed by ref. Side note: you should follow standard conventions and name your methods in PascalCase.
I thought is was lowerCamelCase and UpperCamelCase.
No branches or pull requests
So I was wondering if it's possible to set a variable in a helper method for example:
If this is not possible, can you recommend an alternative solution?
The text was updated successfully, but these errors were encountered: