C# Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 1945 Page Views: 

What is the difference between Close() and Dispose() methods in C#?



Posted By: Avi Date: 4 December 2009 11:14:47 PM
 Answer:

The main difference between Close() and Dispose() method is, when Close() method is called, any managed object can be temporarily closed and can be opened once again. It means that, with the same object the resource can be reopened or used. Whereas Dispose() method permanently removes any resource ((un)managed) from memory for cleanup and the resource no longer exists for any further processing.


Posted By: eTechPlanet


Date: 4 December 2009 11:14:47 PM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image pTpcY1
Related Questions
C# : How can you access system clipboard from c#?

How can you access system clipboard from c#?

By using Clipboard object. For example – SetText – sets text in clipboards, GetText – returns text f....
Category: C# Date: 10/15/2010 2:59:46 AM
C# : How do you start another process from c#?

How do you start another process from c#?

Process p = new Process(); p.StartInfo.FileName =”notepad.exe”; p.Start();
Category: C# Date: 10/15/2010 2:16:47 AM
C# : Can you declare static variable in method scope?

Can you declare static variable in method scope?

No
Category: C# Date: 10/15/2010 12:22:46 AM
C# : What will be the result of code?
int x = 3;
switch(x % 3)
{
 case 0:
 case 1:
  Console.WriteLine(x*2); break;
 default:
  Console.WriteLine(x); break;
}
C# : Write a code to copy file from path1 to path2 using FileStreams and BinaryReader, BinaryWriter

Write a code to copy file from path1 to path2 using FileStreams and BinaryReader, BinaryWriter

s1 = new FileStream(path1, FileMode.Open, FileAccess.Read); s2 = new FileStream(path2, FileMode.Crea....
Category: C# Date: 10/14/2010 8:00:46 PM