Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2007

Tip: Looking for answers? Try searching our database.

interface

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bhuwan Bhaskar - 30 Oct 2007 06:24 GMT
Hi,

How can I use the functions in class / object if they are same in interface.
Code is attached. I want to implement function  f of i1 and i2 in the
objcet.

Thanks and regards.

Bhuwan

interface i1

{

string f();

}

interface i2

{

string f();

}

public class t : i1, i2

{

string i1.f()

{

return ("First");

}

string i2.f()

{

return ("Second");

}
Andrew Faust - 30 Oct 2007 07:04 GMT
You have to caste them to an object of the same type of the interface. From
your example, you would do this:

t mainObject = new t();
Console.WriteLine(((i1) t).f());

or

t mainObject = new t();
i2 two = t;
Console.WriteLine(two.f());

Signature

Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com

> Hi,
>
[quoted text clipped - 41 lines]
>
> }
Bhuwan Bhaskar - 30 Oct 2007 08:18 GMT
Thanks Andrew, it works with little change,

> i2 two = t;

i2 two = mainObject;

Thanks
Bhuwan

> You have to caste them to an object of the same type of the interface.
> From your example, you would do this:
[quoted text clipped - 53 lines]
>>
>> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.