|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
array of interface?Hi,
I understand that I cannot create an instance of an interface, but why is it ok to do the following? What is it creating? foo = New System.ComponentModel.IEditableObject(10) {} whereas the following will get a compiler error ('New' cannot be used on interface): foo = New System.ComponentModel.IEditableObject(10) Thanks, Harold >What is it creating? An 11-element array of the interface type, just like your subjectsays. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. But why is it an error if I don't specify the empty array element
initializer? Sorry, I think I got it. Without the array initializer, it's not
actually an array I'm creating. <haroldsp***@gmail.com> schrieb:
> I understand that I cannot create an instance of an interface, but why An array with items of type 'IEditableObject' containing 11 elements with > is it ok to do the following? What is it creating? > > foo = New System.ComponentModel.IEditableObject(10) {} indices 0 through 10. > whereas the following will get a compiler error ('New' cannot be used In this case the curly braces are required to make the compiler aware that > on interface): > > foo = New System.ComponentModel.IEditableObject(10) an array should be created instead of calling a non-existing constructor. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
How to minimize to system tray ? VS 2003
Keep software running The Irish fada (áéíóú/ÁÉÍÓÚ) and encryption/decryption problem! How to create a "DataSource" & "Items" properties on Custom Combob Working with structures and the New keyword Binding sources question in Vs2005 Encyrption in VB and Decryption in VB.NET Detect Remote Shutdown Alignment problem displaying .txt file in window's textbox? DataTable.Expression |
|||||||||||||||||||||||