Click here to Skip to main content
15,913,854 members
Home / Discussions / C#
   

C#

 
GeneralRe: Object array question Pin
T.Willey3-Oct-06 9:13
T.Willey3-Oct-06 9:13 
AnswerRe: Object array question Pin
Guffa3-Oct-06 9:47
Guffa3-Oct-06 9:47 
GeneralRe: Object array question Pin
T.Willey3-Oct-06 9:59
T.Willey3-Oct-06 9:59 
GeneralRe: Object array question Pin
T.Willey3-Oct-06 12:01
T.Willey3-Oct-06 12:01 
AnswerRe: Object array question Pin
Guffa3-Oct-06 12:29
Guffa3-Oct-06 12:29 
GeneralRe: Object array question Pin
T.Willey3-Oct-06 13:08
T.Willey3-Oct-06 13:08 
QuestionRestore value on exit Pin
peterchen3-Oct-06 6:46
peterchen3-Oct-06 6:46 
AnswerRe: Restore value on exit Pin
Guffa3-Oct-06 9:11
Guffa3-Oct-06 9:11 
You can't use a finalizer that way in .NET, as the finalizer isn't called when the object goes out of scope, but rather when the object is being taken care of by the garbage collector.

IDisposable and using would work. Then you would restore the value in the Dispose method.

The finalizer is usually used as a backup for the disposal, so that the object will be cleaned up when it's collected in case the programmer failed to call Dispose. In this particular case you would probably not want to do anything in the finalizer. If the programmer fails to use the class correctly, it would probably cause more confusion if you change the value back at a later, more or less randomly chosen, time.

You would implement the class for a reference type instead of an int. If you stored a pointer to an int, you would have to make sure that the int stayed pinned in memory while the class exists. For a local variable in a method that would not be a problem as it resides on the stack, but for a member of a class it would, as the garbage collector may move objects around at any time. If you use a reference to an object instead of a pointer that is not a problem, as the reference would be updated if the object moves.


---
b { font-weight: normal; }

QuestionHow to call a function in another application in C#? Pin
zhyluopro3-Oct-06 6:33
zhyluopro3-Oct-06 6:33 
AnswerRe: How to call a function in another application in C#? Pin
CWIZO3-Oct-06 6:38
CWIZO3-Oct-06 6:38 
AnswerRe: How to call a function in another application in C#? Pin
Judah Gabriel Himango3-Oct-06 6:42
sponsorJudah Gabriel Himango3-Oct-06 6:42 
QuestionMath.Something -- Multiple of 10 Pin
drew.perkins3-Oct-06 6:03
drew.perkins3-Oct-06 6:03 
AnswerRe: Math.Something -- Multiple of 10 Pin
Leslie Sanford3-Oct-06 6:22
Leslie Sanford3-Oct-06 6:22 
GeneralRe: Math.Something -- Multiple of 10 Pin
drew.perkins3-Oct-06 6:40
drew.perkins3-Oct-06 6:40 
GeneralRe: Math.Something -- Multiple of 10 [modified] Pin
Alaric_3-Oct-06 7:55
professionalAlaric_3-Oct-06 7:55 
AnswerRe: Math.Something -- Multiple of 10 Pin
User 66583-Oct-06 10:28
User 66583-Oct-06 10:28 
QuestionHelp with Getting info on a running process Pin
UTRocketFan3-Oct-06 5:22
UTRocketFan3-Oct-06 5:22 
AnswerRe: Help with Getting info on a running process Pin
Michael Potter3-Oct-06 6:21
Michael Potter3-Oct-06 6:21 
GeneralRe: Help with Getting info on a running process Pin
UTRocketFan3-Oct-06 7:25
UTRocketFan3-Oct-06 7:25 
AnswerRe: Help with Getting info on a running process Pin
Nader Elshehabi3-Oct-06 6:22
Nader Elshehabi3-Oct-06 6:22 
QuestionQuestion on Visual Studio & Project References Pin
malharone3-Oct-06 5:17
malharone3-Oct-06 5:17 
AnswerRe: Question on Visual Studio & Project References Pin
Colin Angus Mackay3-Oct-06 5:25
Colin Angus Mackay3-Oct-06 5:25 
GeneralRe: Question on Visual Studio & Project References Pin
malharone3-Oct-06 5:39
malharone3-Oct-06 5:39 
GeneralRe: Question on Visual Studio & Project References Pin
malharone3-Oct-06 6:16
malharone3-Oct-06 6:16 
QuestionBindingsource C# Adding New Event Pin
JensB3-Oct-06 4:14
JensB3-Oct-06 4:14 

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.