Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int testCon()
- {
- using (SqlConnection conn = new SqlConnection("Conn string"))
- {
- using (SqlCommand cmd = conn.CreateCommand())
- {
- conn.Open();
- cmd.CommandText = "SELECT COUNT(1) FROM Carsd";
- return (int)cmd.ExecuteScalar();
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- testDispose objTestDispose;
- using (objTestDispose = new testDispose())
- {
- objTestDispose.UserName = "testUser";
- objTestDispose.PassWord = "testPassword";
- }
- Console.WriteLine("Check obj of testDispose Class" + objTestDispose.UserName);
- Console.WriteLine("Check obj of testDispose Class" + objTestDispose.PassWord);
- Console.ReadLine();
- }
- }
- public class testDispose : IDisposable
- {
- public string UserName { get; set; }
- public string PassWord { get; set; }
- public void Dispose()
- { }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement