- 1
what is name this the operation in c#
using(){}
3 Answers
+ 1
Please give some more information. What do you want to know ?
+ 1
Using defines the scope that the object between () is available.
This is usefull with big objects that require a lot of memory or objects that have connections with other resources (files / databases) and you want to make sure it is disposed properly.
So MD5CryptoServiceProvider is created, can be used between the {} and is disposed
The reason for the "using" statement is to ensure that the object is disposed as soon as it goes out of scope
https://stackoverflow.com/questions/75401/uses-of-using-in-c-sharp
0
look
static string En (string value )
{
using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
{
UTF8Encoding ut = new UTF8Encoding();
byte[] data = md5.ComputeHash(ut.GetBytes(value));
return Convert.ToBase64String(data);
}
}
what is the using (){ }