I have this code(heavily modified for your comfort):
string password = Console.ReadLine();
var checker = new Predicate<string>[] { (s) => s == password };
string password2 = CompareStringAgainstPredicatesAndReturn(checker);
The predicate's purpose is to verify that password2 is the same as password. Yet I am getting the following error message: CS1628: Cannot use ref, out, or in parameter 'password' inside an anonymous method, lambda expression, query expression, or local function
I don't know how to parse a variable to the predicate. So how would I go about doing this?
Gonna point out one more time that this is not the actual code. The question is only regarding the actual predicate situation.
As I was afraid, the lack of a complete code caused confusion and understandable misunderstandings. Therefore, here is the full code
string password = BInput.GetPredicateString(
new string[] { "Choose your password" },
"Password: ", //Simply a prompt
"Your password needs to be between 8 to 30 characters long, contain at least 2 numbers and at least one special character", // Error message
new Predicate<string>[] {
(s) => s.Length > 8,
(s) => s.Length < 30,
(s) => s == password,
(s) => Verificator.ContainsSpecialCharacter(s) //Not native
}
);
BInput.GetPredicateString will confirm that the returned string fulfills all requirements within the predicate. This is why the Predicate is an array.
Hoping this brings more clarity, but it's fully possible it doesn't as I've been programming now for 14 hours and brain is like a soggy sponge.
Best regards,