Click here to Skip to main content
15,914,163 members
Home / Discussions / C#
   

C#

 
GeneralRe: get,set methods Pin
Colin Angus Mackay16-Apr-07 4:31
Colin Angus Mackay16-Apr-07 4:31 
GeneralRe: get,set methods Pin
Thomas Stockwell16-Apr-07 10:45
professionalThomas Stockwell16-Apr-07 10:45 
GeneralRe: get,set methods Pin
Luc Pattyn16-Apr-07 4:18
sitebuilderLuc Pattyn16-Apr-07 4:18 
Questionset this object to null Pin
Matglas16-Apr-07 2:51
Matglas16-Apr-07 2:51 
AnswerRe: set this object to null Pin
_mubashir16-Apr-07 3:07
_mubashir16-Apr-07 3:07 
QuestionRe: set this object to null Pin
Matglas16-Apr-07 3:14
Matglas16-Apr-07 3:14 
AnswerRe: set this object to null Pin
Colin Angus Mackay16-Apr-07 3:20
Colin Angus Mackay16-Apr-07 3:20 
AnswerRe: set this object to null Pin
Luc Pattyn16-Apr-07 3:26
sitebuilderLuc Pattyn16-Apr-07 3:26 
Hi,

an object can not set itself to null.
an object is a piece of code+data, and what you use to access an object
really is a reference (often also called object, but that is not strictly correct).

Now an object cannot access its reference(s) in general, since an object is
not aware of its references.

In special cases you can do something, but that requires you get access to the
reference, typically by using the ref keyword, as in:

    Nullable A=new Nullable();
    a.NullifyMyRef(ref a);
    a.Something();    // NullPointerException !

class Nullable {
    public void NullifyMyRef(object ref obj) {
        obj=null;
    }
}



But what is the use of all this ???
Most scenarios I can come up with are a result of bad OO practices.
The one good use I could come up with is something like the Dispose() method
that may want to nullify its own reference; the fact that it does not proves
to me once more it can not be done.

Smile | :)





Luc Pattyn

[My Articles]

AnswerRe: set this object to null Pin
Colin Angus Mackay16-Apr-07 3:18
Colin Angus Mackay16-Apr-07 3:18 
QuestionRe: set this object to null Pin
Matglas16-Apr-07 3:31
Matglas16-Apr-07 3:31 
AnswerRe: set this object to null Pin
Dan Neely16-Apr-07 3:37
Dan Neely16-Apr-07 3:37 
GeneralRe: set this object to null Pin
Matglas16-Apr-07 3:50
Matglas16-Apr-07 3:50 
GeneralRe: set this object to null Pin
Matglas16-Apr-07 3:42
Matglas16-Apr-07 3:42 
QuestionRichtext Box undo Pin
7116-Apr-07 2:42
7116-Apr-07 2:42 
AnswerRe: Richtext Box undo Pin
Pete O'Hanlon16-Apr-07 2:50
mvePete O'Hanlon16-Apr-07 2:50 
QuestionC# Threading Controls on a Form Pin
ATCsharp16-Apr-07 2:41
ATCsharp16-Apr-07 2:41 
AnswerRe: C# Threading Controls on a Form Pin
Martin#16-Apr-07 2:46
Martin#16-Apr-07 2:46 
GeneralRe: C# Threading Controls on a Form Pin
ATCsharp16-Apr-07 2:52
ATCsharp16-Apr-07 2:52 
AnswerRe: C# Threading Controls on a Form Pin
Leslie Sanford16-Apr-07 3:51
Leslie Sanford16-Apr-07 3:51 
Questionconverting C++ pseudo-code to C#.NET [modified] Pin
Software_Specialist16-Apr-07 1:50
Software_Specialist16-Apr-07 1:50 
AnswerRe: converting C++ pseudo-code to C#.NET Pin
Stefan Troschuetz16-Apr-07 2:20
Stefan Troschuetz16-Apr-07 2:20 
GeneralRe: converting C++ pseudo-code to C#.NET Pin
Software_Specialist16-Apr-07 2:43
Software_Specialist16-Apr-07 2:43 
AnswerRe: converting C++ pseudo-code to C#.NET Pin
sulabh202016-Apr-07 2:24
sulabh202016-Apr-07 2:24 
GeneralRe: converting C++ pseudo-code to C#.NET Pin
Software_Specialist16-Apr-07 3:39
Software_Specialist16-Apr-07 3:39 
QuestionWindows Scheduled Tasks Pin
karthik_dotnet116-Apr-07 1:38
karthik_dotnet116-Apr-07 1:38 

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.