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. Windows Forms
  4. Interface

Interface

Scheduled Pinned Locked Moved Windows Forms
csharpquestioncareer
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.
  • L Lost User

    Ahamed Azeem wrote:

    Tell me an real time use of an interface.

    The question is rather unclear; it sounds as if you're requesting for an example of an interface in a real-time environment, but I'm going to guess that you want a practical example where we use interfaces. How about IDbConnection and IDbCommand?

    Ahamed Azeem wrote:

    Apart from importing namespace is there any use for "Using" keyword in C#.net.

    Yup, both as a naming-alias for existing namespaces, as well as defining scope for a class that implements IDisposable.

    I are Troll :suss:

    A Offline
    A Offline
    Ahamed Azeem
    wrote on last edited by
    #3

    Thank your for your reply. Why do we want to go for interfaces rather than normal method definition. Your second answer is not clear to me. Could you pls explain more Regards Azeem

    L 1 Reply Last reply
    0
    • A Ahamed Azeem

      Thank your for your reply. Why do we want to go for interfaces rather than normal method definition. Your second answer is not clear to me. Could you pls explain more Regards Azeem

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #4

      Ahamed Azeem wrote:

      Why do we want to go for interfaces rather than normal method definition.

      Mostly to prevent thight coupling, but there may be other reasons. An interface just says how the "normal method definition" should look, it doesn't contain any implementation; that means that if a class implements an interface that you can be sure that this class has all the properties and methods that are defined within the interface. A variable of the type IDbConnection can hold a SqlConnection or a OracleClientConnection. You could only talk to Sql Express if you used a SqlConnection variable. There's a better explanation of that idea over here[^].

      Ahamed Azeem wrote:

      Your second answer is not clear to me. Could you pls explain more

      The first alternative usage is a namespace alias[^]. That would allow you to "rename" the namespace. This is common in Office-development to shorten the namespaces. As an example;

      static class SomeClass
      {
      static void someMethod ()
      {
      System.Diagnostics.Debug.WriteLine("bla");
      }
      }

      With a namespace-alias, it would look like this;

      using Diag = System.Diagnostics;
      static class SomeClass
      {
      static void someMethod ()
      {
      Diag.Debug.WriteLine("bla");
      }
      }

      The second alternative[^] use is what the "interviewer" wanted to hear, and looks like this;

      using (Font font1 = new Font("Arial", 10.0f))
      {
      byte charset = font1.GdiCharSet;
      }

      This ensures that IDisposable is called cleaning up the Font.

      Happy Reading :)

      A 1 Reply Last reply
      0
      • A Ahamed Azeem

        Hello, In an interview asked to me that, Tell me an real time use of an interface. Apart from importing namespace is there any use for "Using" keyword in C#.net. Could anybody can answer these question. I would be very thankful to you Regards Azeem

        D Offline
        D Offline
        dan sh
        wrote on last edited by
        #5

        Ahamed Azeem wrote:

        real time use of an interface

        This is what I can think right away: I am owner of an application. There are two distant and independent teams which are working on it. One on UI and other on rest of the layers. Now, as an owner, what I can do is provide both the teams with a interfaces so that they can work independently and be sure of what is the middle and DB layer is going to offer and what UI is supposed to consume. There are plenty more uses of interfaces, one being dependency injection, which you might find through google. :)

        1 Reply Last reply
        0
        • A Ahamed Azeem

          Hello, In an interview asked to me that, Tell me an real time use of an interface. Apart from importing namespace is there any use for "Using" keyword in C#.net. Could anybody can answer these question. I would be very thankful to you Regards Azeem

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #6

          Hi, IMO you should buy and study a book on C# or change your career plans; those were very basic questions after all. :|

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          Getting an article published on CodeProject should be easier and faster.


          L A 2 Replies Last reply
          0
          • L Luc Pattyn

            Hi, IMO you should buy and study a book on C# or change your career plans; those were very basic questions after all. :|

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


            Getting an article published on CodeProject should be easier and faster.


            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #7

            :thumbsup:

            1 Reply Last reply
            0
            • A Ahamed Azeem

              Hello, In an interview asked to me that, Tell me an real time use of an interface. Apart from importing namespace is there any use for "Using" keyword in C#.net. Could anybody can answer these question. I would be very thankful to you Regards Azeem

              A Offline
              A Offline
              Abhinav S
              wrote on last edited by
              #8

              Ahamed Azeem wrote:

              for "Using"

              Real time use of an interface - Late binding. "Using" is often used to define a scope inside which an object will be garbage collected. As suggested, you need to pick up a good C# book and read.

              Me, I'm dishonest. And a dishonest man you can always trust to be dishonest.
              Honestly. It's the honest ones you want to watch out for...

              1 Reply Last reply
              0
              • L Luc Pattyn

                Hi, IMO you should buy and study a book on C# or change your career plans; those were very basic questions after all. :|

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                Getting an article published on CodeProject should be easier and faster.


                A Offline
                A Offline
                Ahamed Azeem
                wrote on last edited by
                #9

                Dear Gentleman, Is there any rule that basic question would not be answered.. I am very good fan of this forum. Regards Azeem

                D 1 Reply Last reply
                0
                • L Lost User

                  Ahamed Azeem wrote:

                  Why do we want to go for interfaces rather than normal method definition.

                  Mostly to prevent thight coupling, but there may be other reasons. An interface just says how the "normal method definition" should look, it doesn't contain any implementation; that means that if a class implements an interface that you can be sure that this class has all the properties and methods that are defined within the interface. A variable of the type IDbConnection can hold a SqlConnection or a OracleClientConnection. You could only talk to Sql Express if you used a SqlConnection variable. There's a better explanation of that idea over here[^].

                  Ahamed Azeem wrote:

                  Your second answer is not clear to me. Could you pls explain more

                  The first alternative usage is a namespace alias[^]. That would allow you to "rename" the namespace. This is common in Office-development to shorten the namespaces. As an example;

                  static class SomeClass
                  {
                  static void someMethod ()
                  {
                  System.Diagnostics.Debug.WriteLine("bla");
                  }
                  }

                  With a namespace-alias, it would look like this;

                  using Diag = System.Diagnostics;
                  static class SomeClass
                  {
                  static void someMethod ()
                  {
                  Diag.Debug.WriteLine("bla");
                  }
                  }

                  The second alternative[^] use is what the "interviewer" wanted to hear, and looks like this;

                  using (Font font1 = new Font("Arial", 10.0f))
                  {
                  byte charset = font1.GdiCharSet;
                  }

                  This ensures that IDisposable is called cleaning up the Font.

                  Happy Reading :)

                  A Offline
                  A Offline
                  Ahamed Azeem
                  wrote on last edited by
                  #10

                  Thanks a lot.. now i got it Regards Azeem

                  1 Reply Last reply
                  0
                  • A Ahamed Azeem

                    Dear Gentleman, Is there any rule that basic question would not be answered.. I am very good fan of this forum. Regards Azeem

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #11

                    That's not the problem. The problem is that you were interviewing for a C# job without knowing the most basic concepts of C# and OOP programming.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007, 2008
                    But no longer in 2009...

                    A 1 Reply Last reply
                    0
                    • D Dave Kreskowiak

                      That's not the problem. The problem is that you were interviewing for a C# job without knowing the most basic concepts of C# and OOP programming.

                      A guide to posting questions on CodeProject[^]
                      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                           2006, 2007, 2008
                      But no longer in 2009...

                      A Offline
                      A Offline
                      Ahamed Azeem
                      wrote on last edited by
                      #12

                      Thank you

                      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