Here is Sample Code for Understanding Use of " Using "
using(SqlConnection con= new SqlConnection(connectionString) )
SqlCommand cmd = new SqlCommand(commandString, sqlconnection);
using (SqlDataReader reader = cmd.ExecuteReader())
"Using" keyword takes the parameter of type IDisposable.
Whenever you are using any IDisposable type object you should use the "using" keyword to handle automatically when it should close or dispose.
Internally using keyword calls the Dispose() method to dispose the IDisposable object.
Object is disposed automatically on the end of this statement.
For is and as operator
it is use for check casting and return Boolean value.
check for more details
Sivakumar.S, if this helps please login to Mark As Answer. |
Reply | Alert Moderator