Using an Interface with my Managers

Posts   
 
    
Ceres
User
Posts: 20
Joined: 31-Jan-2007
# Posted on: 03-Mar-2008 00:12:38   

Hi, Using WinForm, Adapter 2.5 & VB

Am extending the RemotingServices example and have a dumb question flushed

In my Gui I can use the following code to fetch Customer("CHOPS") via the GetCustomer method in CustomerManager.

Dim customer as New CustomerManager
BindingSource1.DataSource = customer.GetCustomer("CHOPS")

If I now use a CustomerManager interface, how do I get round the fact that the New keyword cannot be used on an Interface?

If I do the following:

Dim customer as ICustomerManager
BindingSource1.DataSource = customer.GetCustomer("CHOPS")

... is it safe to ignore the warning Variable 'customer' is used before it has been assigned a value ?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-Mar-2008 10:37:33   

An interface should have an implementation, and while you can define a variable from an interface, yet it should be instantiated from a class implementing the interface before using it.