Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Difference between Instance and Object

Difference between Instance and Object

Scheduled Pinned Locked Moved C#
csharpquestion
12 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Manas Bhardwaj

    Instance refers to the copy of the object at a particular time whereas object refers to the memory address of the class.

    Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

    N Offline
    N Offline
    NET India
    wrote on last edited by
    #3

    Class A { public void get() { Console.WriteLine("Hello"); } } Public Static Void Main(..) { A e=new A();/b> e.get(); } Here, A e=new A(); is instance or object Can you expain a bit more

    J S G 3 Replies Last reply
    0
    • N NET India

      Class A { public void get() { Console.WriteLine("Hello"); } } Public Static Void Main(..) { A e=new A();/b> e.get(); } Here, A e=new A(); is instance or object Can you expain a bit more

      S Offline
      S Offline
      Shpendh
      wrote on last edited by
      #4

      A is the object, and e is the Instance, through the instance you can access the method you have in the Class, you cannot access to the method without creating the instance...

      spaps

      1 Reply Last reply
      0
      • N NET India

        Class A { public void get() { Console.WriteLine("Hello"); } } Public Static Void Main(..) { A e=new A();/b> e.get(); } Here, A e=new A(); is instance or object Can you expain a bit more

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #5

        Its an instance of an object ;)

        B 1 Reply Last reply
        0
        • J J4amieC

          Its an instance of an object ;)

          B Offline
          B Offline
          blackjack2150
          wrote on last edited by
          #6

          Hmmm... terminology is a bit blurry perhaps. Isn't object equivalent to instance? In school we learned that "An object is the result of instantiating a class". So if we have the class 'Dog', Spike and Lassie are objects of type 'Dog' or instances of the 'Dog' class. Just like objects in real life...

          G 1 Reply Last reply
          0
          • B blackjack2150

            Hmmm... terminology is a bit blurry perhaps. Isn't object equivalent to instance? In school we learned that "An object is the result of instantiating a class". So if we have the class 'Dog', Spike and Lassie are objects of type 'Dog' or instances of the 'Dog' class. Just like objects in real life...

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #7

            blackjack2150 wrote:

            Hmmm... terminology is a bit blurry perhaps. Isn't object equivalent to instance?

            The terms class and instance are pretty clear. The term object on the other hand is trickier, as it's sometimes used to mean a class, sometimes used to mean any instance of a class, and sometimes used to mean a specific instance of a class.

            Despite everything, the person most likely to be fooling you next is yourself.

            N 1 Reply Last reply
            0
            • G Guffa

              blackjack2150 wrote:

              Hmmm... terminology is a bit blurry perhaps. Isn't object equivalent to instance?

              The terms class and instance are pretty clear. The term object on the other hand is trickier, as it's sometimes used to mean a class, sometimes used to mean any instance of a class, and sometimes used to mean a specific instance of a class.

              Despite everything, the person most likely to be fooling you next is yourself.

              N Offline
              N Offline
              NET India
              wrote on last edited by
              #8

              So wht's a differnce between Instance and Object ????????????? A e=new A(); Here A is Object and e is instance Is it ryt as mentioned by one of the member above

              G 1 Reply Last reply
              0
              • N NET India

                Class A { public void get() { Console.WriteLine("Hello"); } } Public Static Void Main(..) { A e=new A();/b> e.get(); } Here, A e=new A(); is instance or object Can you expain a bit more

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #9

                .NET- India wrote:

                Here, A e=new A(); is instance or object

                The term object is not very clear, as both the class A and an instance of the class A can be called an object. e is a variable that can hold a reference to an instance of the class A (or any of it's decendants if there were any). new A() creates an instance of the class A. The value of the expression is the reference to the created instance, which is stored in the variable e.

                Despite everything, the person most likely to be fooling you next is yourself.

                N 1 Reply Last reply
                0
                • G Guffa

                  .NET- India wrote:

                  Here, A e=new A(); is instance or object

                  The term object is not very clear, as both the class A and an instance of the class A can be called an object. e is a variable that can hold a reference to an instance of the class A (or any of it's decendants if there were any). new A() creates an instance of the class A. The value of the expression is the reference to the created instance, which is stored in the variable e.

                  Despite everything, the person most likely to be fooling you next is yourself.

                  N Offline
                  N Offline
                  NET India
                  wrote on last edited by
                  #10

                  Actuallly sir in an interview i was asked this question "What is the difference between Instance and Object". So how should i define it??????

                  G 1 Reply Last reply
                  0
                  • N NET India

                    So wht's a differnce between Instance and Object ????????????? A e=new A(); Here A is Object and e is instance Is it ryt as mentioned by one of the member above

                    G Offline
                    G Offline
                    Guffa
                    wrote on last edited by
                    #11

                    .NET- India wrote:

                    So wht's a differnce between Instance and Object ?????????????

                    A big difference and none at all. It seems like your question mark key is stuck. Have you spilled too much cola in the keyboard? ;)

                    .NET- India wrote:

                    A e=new A(); Here A is Object and e is instance Is it ryt as mentioned by one of the member above

                    A is a class, and it can be called an object, but also an instance of the class A can be called an object. The variable e is not at all an instance of the class, it's a reference variable that can hold a reference to an instance of the class A.

                    Despite everything, the person most likely to be fooling you next is yourself.

                    1 Reply Last reply
                    0
                    • N NET India

                      Actuallly sir in an interview i was asked this question "What is the difference between Instance and Object". So how should i define it??????

                      G Offline
                      G Offline
                      Guffa
                      wrote on last edited by
                      #12

                      Just clarify that the term object is used for both classes and instances in different situations, and explain the relation between classes and instances.

                      Despite everything, the person most likely to be fooling you next is yourself.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups