Results 1 to 2 of 2

Thread: Help explaining come code (interfaces)

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Help explaining come code (interfaces)

    Hello,

    I have some code that I have written from a tutorial. Even though I understand what the code is doing. I don't understand some of the coding itself.

    Meaning this:
    Code:
    IDeviceEmulatorManager emulatorManager;
    and this:
    Code:
    emulatorManager = new DeviceEmulatorManagerClass();
    I can understand that is creating a object of the DeviceEmulatorManagerClass so you can you its methods and properties etc. But I am not sure of why you need the interface?

    Many thanks for any advice,

    Steve

    The complete code is listed below.
    Code:
    IDeviceEmulatorManager emulatorManager;
            private void Form1_Load(object sender, EventArgs e)
            {
                emulatorManager = new DeviceEmulatorManagerClass();
    
            }
    
            private void btnPopulate_Click(object sender, EventArgs e)
            {
                this.ListDEMAllMembers();
            }
    
            void ListDEMAllMembers()
            {
                string categoryName;
                this.lstDisplay.Items.Clear();
                emulatorManager.Reset();
    
                    while (true)
                    {
                        categoryName = emulatorManager.get_Name();
                        lstDisplay.Items.Add(categoryName);
    
                        emulatorManager.MoveNext();
    
                    }
                
            }
    steve

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Help explaining come code (interfaces)

    From this MSDN topic, which I found by searching for deviceemulatormanagerclass:
    To get started with the Device Emulator Manager API, you must first create an instance of the Device Emulator Manager. You do this by creating an instance of the DeviceEmulatorManagerClass class. This class encapsulates the COM component that represents the Device Emulator Manager. When working with the Device Emulator Manager, you can use the DeviceEmulatorManagerClass class directly or use the IDeviceEmulatorManager interface. Both the class and the interface provide all of the same methods. For consistency with the interface-based nature of COM, this paper uses the interface as shown in the following code sample.
    Code:
    IDeviceEmulatorManager _emulatorManager;
    _emulatorManager = new DeviceEmulatorManagerClass();
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width