Click here to Skip to main content
15,885,767 members
Home / Discussions / C#
   

C#

 
GeneralRe: Waiting Progress Bar (knight ride stylee) Pin
Paresh Gheewala17-Apr-03 11:37
Paresh Gheewala17-Apr-03 11:37 
GeneralRemoting and Finalize Pin
Adam Turner16-Apr-03 19:15
Adam Turner16-Apr-03 19:15 
GeneralRe: Remoting and Finalize Pin
Philip Fitzsimons17-Apr-03 4:26
Philip Fitzsimons17-Apr-03 4:26 
GeneralRe: Remoting and Finalize Pin
Adam Turner17-Apr-03 16:20
Adam Turner17-Apr-03 16:20 
GeneralRe: Remoting and Finalize Pin
Paresh Gheewala17-Apr-03 12:39
Paresh Gheewala17-Apr-03 12:39 
GeneralRe: Remoting and Finalize Pin
Adam Turner17-Apr-03 16:19
Adam Turner17-Apr-03 16:19 
GeneralGetting current instance of another class Pin
Meysam Mahfouzi16-Apr-03 18:03
Meysam Mahfouzi16-Apr-03 18:03 
GeneralRe: Getting current instance of another class Pin
Jim Stewart16-Apr-03 20:27
Jim Stewart16-Apr-03 20:27 
Having two classes is not the same as having two objects. The this keyword refers to the current instance defined by a class. So, from within the class definition of an object, one may retrieve a reference to and operate on itself using this. However, current instance has no meaning with regard to any other object (including other ClassBs) without some context: e. g. being passed or instanciating a reference to that other class. Consider: what does current instance mean if there are ten instances? Which one is current?

C#
class ClassA
{ 
    public Foo()
    { ... }
}

class ClassB
{
    ClassB(ClassA classA)
    {
        classA.Foo ();  // A reference to a ClassA object
        this.Bar ();    // A reference to this particular instance<br>
        ClassB classB = new ClassB (classA);                        
        classB.Bar ();  // A new ClassB reference
    }

    public Bar()
    { ... }

    static Main()
    { 
        ClassA cA1 = new ClassA ();
        ClassA cA2 = new ClassA ();
        ...
        ClassA cA10 = new ClassA ();

        ClassB cB = new ClassB (cA1);
    }
}

In Main() there are ten instances of ClassA (cA1 - cA10) and one of ClassB (cB). The only (non-static) objects that cB may operate on are

  • itself
  • ClassA instance cA1
  • the internally created instance of ClassB: classB

I sure hope this helps.

α.γεεκ

Fortune passes everywhere.
Duke Leto Atreides


GeneralRe: Getting current instance of another class Pin
Meysam Mahfouzi18-Apr-03 17:22
Meysam Mahfouzi18-Apr-03 17:22 
GeneralRe: Getting current instance of another class Pin
Paresh Gheewala17-Apr-03 12:31
Paresh Gheewala17-Apr-03 12:31 
GeneralDotfuscator VS.Net license? need URL Pin
Bog16-Apr-03 17:05
Bog16-Apr-03 17:05 
GeneralRe: Dotfuscator VS.Net license? need URL Pin
James T. Johnson16-Apr-03 18:45
James T. Johnson16-Apr-03 18:45 
GeneralRe: Dotfuscator VS.Net license? need URL Pin
Roger Alsing16-Apr-03 20:43
Roger Alsing16-Apr-03 20:43 
Generalopening File Pin
plextoR16-Apr-03 12:19
plextoR16-Apr-03 12:19 
GeneralSaving file & opening it form another app Pin
plextoR16-Apr-03 12:03
plextoR16-Apr-03 12:03 
GeneralRe: Saving file & opening it form another app Pin
Paresh Gheewala17-Apr-03 12:30
Paresh Gheewala17-Apr-03 12:30 
GeneralRe: Saving file & opening it form another app Pin
plextoR17-Apr-03 13:11
plextoR17-Apr-03 13:11 
GeneralC# forms[design] Pin
davidj0x116-Apr-03 11:37
davidj0x116-Apr-03 11:37 
GeneralRe: C# forms[design] Pin
Andres Manggini16-Apr-03 13:25
Andres Manggini16-Apr-03 13:25 
GeneralRe: C# forms[design] Pin
davidj0x117-Apr-03 5:36
davidj0x117-Apr-03 5:36 
GeneralListview item click events Pin
vlusardi16-Apr-03 10:46
vlusardi16-Apr-03 10:46 
GeneralRe: Listview item click events Pin
James T. Johnson16-Apr-03 14:12
James T. Johnson16-Apr-03 14:12 
GeneralRe: Listview item click events Pin
chito16-Apr-03 16:24
chito16-Apr-03 16:24 
GeneralRe: Listview item click events Pin
vlusardi17-Apr-03 11:00
vlusardi17-Apr-03 11:00 
QuestionSqlDataAdapter .Fill() using DataTable instead of DataSet? Pin
zoltan_ie16-Apr-03 7:15
zoltan_ie16-Apr-03 7:15 

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.