anyone knows a way to solute this smart?
public static void Invert(this ref bool value)
{
value = !value;
}
c# says i can not use “ref” or “out” within an extension. But such extensions like List.Clear() exist.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
List.Clear()isn’t an extension method, it’s a method. And even if it was an extension method, it wouldn’t need to receive the parameter asref, because it doesn’t “return” a different list than the one you had, it modifies the list.And, in general, you can’t. But you normally don’t need to.
What about: