Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 132,685 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,256 people online right now. Registration is fast and FREE... Join Now!




returning an array of an interface

 
Reply to this topicStart new topic

returning an array of an interface

johnholton
post 2 Jun, 2008 - 12:49 AM
Post #1


New D.I.C Head

*
Joined: 22 Apr, 2008
Posts: 4

I've defined and Interface call IBar. Bar inherits from this IBar

now I have a function call, but the last line fails. How do I return an array of interfaces?

IBar [] getAllBars()

{

Bar [] b = new Bar[100];

return b;
}
User is offlineProfile CardPM

Go to the top of the page

baavgai
post 2 Jun, 2008 - 03:23 AM
Post #2


Dreaming Coder

Group Icon
Joined: 16 Oct, 2007
Posts: 1,967



Thanked 96 times

Dream Kudos: 475

Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions


Looks ok. You can try this:
CODE

return (IBar [])b;


or this
CODE

IBar [] b = new Bar[100];


Either should work.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 07:06AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month