I was looking up how to do something when I cam upon a bit of example code that had the following format:
public static SecureString ConvertToSecureString(this string password)
{
// stuff
}
What does that “this” do?
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.
It makes it an extension method, meaning you will be able to do:
It basically adds functionality to any instance of an object of the type that comes after the keyword “this” in there.
You can read more about extension methods here.