Click here to Skip to main content
15,889,651 members
Home / Discussions / C#
   

C#

 
GeneralGet Button Pin
The underdog25-Apr-05 2:51
The underdog25-Apr-05 2:51 
GeneralRe: Get Button Pin
Ashok Dhamija25-Apr-05 3:29
Ashok Dhamija25-Apr-05 3:29 
GeneralRe: Get Button Pin
Le centriste25-Apr-05 3:46
Le centriste25-Apr-05 3:46 
GeneralRe: Get Button Pin
mav.northwind25-Apr-05 3:52
mav.northwind25-Apr-05 3:52 
GeneralRe: Get Button Pin
Luis Alonso Ramos25-Apr-05 5:49
Luis Alonso Ramos25-Apr-05 5:49 
GeneralDiferences between null,close and dispose Pin
Enishi25-Apr-05 1:48
Enishi25-Apr-05 1:48 
GeneralRe: Diferences between null,close and dispose Pin
S. Senthil Kumar25-Apr-05 3:32
S. Senthil Kumar25-Apr-05 3:32 
GeneralRe: Diferences between null,close and dispose Pin
turbochimp25-Apr-05 5:54
turbochimp25-Apr-05 5:54 
The previous post is not entirely correct. Close() and Dispose() do not do the same thing with respect to a SqlConnection. It is true that Dispose() will close the connection if the ConnectionState is Open, but the converse is not true: if Close() is called, the SqlConnection is not disposed, and your initial assertion is correct - the connection may be re-opened.

In general, the following should ideally be true for disposable types (the concept of Close is not covered, since it doesn't really apply to the discussion, and may mean different things to different types - file streams, database connections, sockets etc.):

1. Dispose() should be responsible for cleaning up unmanaged resources and indicating to the GC that finalization is suppressed for the instance (suppressing finalization explicitly avoids the default two-pass collection of collectible objects). The value of Dispose() is that unmanaged resources can be reclaimed immediately (or nearly so), without waiting for the GC. Suppressing finalization for the object serves to streamline the garbage collection process so that it takes only one pass to reclaim the managed resources used by the object instead of two passes (one to finalize, one to reclaim).

2. Setting an object to null just drops a reference to the object, essentially setting it adrift in the (managed) heap until the GC executes and begins cleaning it up. There is no guarantee about when the resources for that object will be reclaimed.

For more info, look here.[^]

Hope this helps.

The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’

GeneralRe: Diferences between null,close and dispose Pin
S. Senthil Kumar25-Apr-05 19:22
S. Senthil Kumar25-Apr-05 19:22 
GeneralRe: Diferences between null,close and dispose Pin
mav.northwind25-Apr-05 20:27
mav.northwind25-Apr-05 20:27 
GeneralRe: Diferences between null,close and dispose Pin
S. Senthil Kumar26-Apr-05 0:33
S. Senthil Kumar26-Apr-05 0:33 
GeneralRe: Diferences between null,close and dispose Pin
turbochimp26-Apr-05 5:10
turbochimp26-Apr-05 5:10 
GeneralRe: Diferences between null,close and dispose Pin
S. Senthil Kumar26-Apr-05 19:17
S. Senthil Kumar26-Apr-05 19:17 
GeneralRe: Diferences between null,close and dispose Pin
turbochimp27-Apr-05 5:19
turbochimp27-Apr-05 5:19 
GeneralRe: Diferences between null,close and dispose Pin
Tom Larsen25-Apr-05 9:31
Tom Larsen25-Apr-05 9:31 
GeneralRe: Diferences between null,close and dispose Pin
Enishi25-Apr-05 22:08
Enishi25-Apr-05 22:08 
GeneralCopy an excel document Pin
fatihsen25-Apr-05 1:34
fatihsen25-Apr-05 1:34 
GeneralRe: Copy an excel document Pin
turbochimp25-Apr-05 2:49
turbochimp25-Apr-05 2:49 
General[ActiveDirectory] Connect to group Pin
Jaymz66625-Apr-05 1:05
Jaymz66625-Apr-05 1:05 
Generalmixer - balance settings Pin
Mr.Dani25-Apr-05 0:24
Mr.Dani25-Apr-05 0:24 
QuestionHow to bind IList to a DataGridTableStyle? Pin
Member 59674924-Apr-05 23:15
Member 59674924-Apr-05 23:15 
AnswerRe: How to bind IList to a DataGridTableStyle? Pin
Anonymous25-Apr-05 1:08
Anonymous25-Apr-05 1:08 
Generalselecting row from datagrid Pin
anj198324-Apr-05 23:06
anj198324-Apr-05 23:06 
GeneralRe: selecting row from datagrid Pin
Polis Pilavas25-Apr-05 9:19
Polis Pilavas25-Apr-05 9:19 
Generalcontrol another pc in lan Pin
mtbjr24-Apr-05 22:31
mtbjr24-Apr-05 22:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.