|
Hello
I was just got VS 2005 preview, and was trying generics.
I tried the following code
int[] intArray = new int[100];
IList<int> intList = (IList<int>) intArray;
it didn't compile, also the following didn't compile
IEnumerable<int> intEnumerable = (IEnumerable<int>)intArray;
IMHO it makes perfect sense that int[] should implement IList<int>,
IEnumerable<int>, etc, since it implements the non-generic IList, and
IEnumerable.
Best regards,
Sherif | |
Share:
|
Please, post whidbey questions to the private whidbey NG, This NG is for
released products.
Willy.
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl... Hello
I was just got VS 2005 preview, and was trying generics.
I tried the following code
int[] intArray = new int[100]; IList<int> intList = (IList<int>) intArray;
it didn't compile, also the following didn't compile
IEnumerable<int> intEnumerable = (IEnumerable<int>)intArray;
IMHO it makes perfect sense that int[] should implement IList<int>, IEnumerable<int>, etc, since it implements the non-generic IList, and IEnumerable.
Best regards, Sherif
| | |
Please, post whidbey questions to the private whidbey NG, This NG is for
released products.
Willy.
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl... Hello
I was just got VS 2005 preview, and was trying generics.
I tried the following code
int[] intArray = new int[100]; IList<int> intList = (IList<int>) intArray;
it didn't compile, also the following didn't compile
IEnumerable<int> intEnumerable = (IEnumerable<int>)intArray;
IMHO it makes perfect sense that int[] should implement IList<int>, IEnumerable<int>, etc, since it implements the non-generic IList, and IEnumerable.
Best regards, Sherif
| | |
Sherif,
Given that System.Array implements IList and IEnumerable, the
specialized versions should definitely be supported.
I'll file a bug. Thanks for finding it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl... Hello
I was just got VS 2005 preview, and was trying generics.
I tried the following code
int[] intArray = new int[100]; IList<int> intList = (IList<int>) intArray;
it didn't compile, also the following didn't compile
IEnumerable<int> intEnumerable = (IEnumerable<int>)intArray;
IMHO it makes perfect sense that int[] should implement IList<int>, IEnumerable<int>, etc, since it implements the non-generic IList, and IEnumerable.
Best regards, Sherif
| | |
Sherif,
Given that System.Array implements IList and IEnumerable, the
specialized versions should definitely be supported.
I'll file a bug. Thanks for finding it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl... Hello
I was just got VS 2005 preview, and was trying generics.
I tried the following code
int[] intArray = new int[100]; IList<int> intList = (IList<int>) intArray;
it didn't compile, also the following didn't compile
IEnumerable<int> intEnumerable = (IEnumerable<int>)intArray;
IMHO it makes perfect sense that int[] should implement IList<int>, IEnumerable<int>, etc, since it implements the non-generic IList, and IEnumerable.
Best regards, Sherif
| | |
Nicholas Paldino [.NET/C# MVP] wrote: Sherif,
Given that System.Array implements IList and IEnumerable, the specialized versions should definitely be supported.
I'll file a bug. Thanks for finding it.
I don't think this is going to be possible without creating
System.Int32Array, System.StringArray, etc.
Example:
int[] array1 = new int[100];
string[] array2 = new string[50];
Both of these objects (array1 and array2) are of type System.Array. How
can one of them implement IList<int> and the other implement
IList<string>? How could the compiler have any way of knowing which
interfaces are implemented by which instances?
There just isn't a way for two instances of the same type to implement
different interfaces; it breaks way too many OOP rules. | | |
Kevin,
You misunderstood the implication that I was making. Basically, because
System.Array (the general base for all arrays) implements IList, and
IEnumerable, the specialized arrays (int[], string[], etc, etc) should also
implement the specialized versions (IList<int> and IEnumerable<int>) as
well.
Also, array1 and array2 are not of type System.Array. Rather, they
derive from System.Array. Because of this, it is easy for the derivation to
implement IList<T>.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Kevin P. Fleming" <kp*******@backtobasicsmgmt.com> wrote in message
news:ud*************@TK2MSFTNGP09.phx.gbl... Nicholas Paldino [.NET/C# MVP] wrote:
Sherif,
Given that System.Array implements IList and IEnumerable, the specialized versions should definitely be supported.
I'll file a bug. Thanks for finding it.
I don't think this is going to be possible without creating System.Int32Array, System.StringArray, etc.
Example:
int[] array1 = new int[100]; string[] array2 = new string[50];
Both of these objects (array1 and array2) are of type System.Array. How can one of them implement IList<int> and the other implement IList<string>? How could the compiler have any way of knowing which interfaces are implemented by which instances?
There just isn't a way for two instances of the same type to implement different interfaces; it breaks way too many OOP rules. | | |
Nicholas Paldino [.NET/C# MVP] wrote: You misunderstood the implication that I was making. Basically, because System.Array (the general base for all arrays) implements IList, and IEnumerable, the specialized arrays (int[], string[], etc, etc) should also implement the specialized versions (IList<int> and IEnumerable<int>) as well.
Also, array1 and array2 are not of type System.Array. Rather, they derive from System.Array. Because of this, it is easy for the derivation to implement IList<T>.
OK, I did not realize that array1 and array2 would be instances of a
type derived from System.Array. Is this true whenever I declare any
array? I was not aware that the C# compiler created hidden types to be
used to implement arrays. I guess it must, otherwise array1[0] would be
a System.Object, not a System.Int32.
Given this information, implementing the IList and IEnumerator generics
would be relatively easy and quite useful. | | |
Kevin,
This is true when you delcare any array. Your array type is T[]. The
base of T[] is System.Array.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Kevin P. Fleming" <kp*******@backtobasicsmgmt.com> wrote in message
news:uU*************@tk2msftngp13.phx.gbl... Nicholas Paldino [.NET/C# MVP] wrote:
You misunderstood the implication that I was making. Basically,
because System.Array (the general base for all arrays) implements IList, and IEnumerable, the specialized arrays (int[], string[], etc, etc) should
also implement the specialized versions (IList<int> and IEnumerable<int>) as well.
Also, array1 and array2 are not of type System.Array. Rather, they derive from System.Array. Because of this, it is easy for the
derivation to implement IList<T>.
OK, I did not realize that array1 and array2 would be instances of a type derived from System.Array. Is this true whenever I declare any array? I was not aware that the C# compiler created hidden types to be used to implement arrays. I guess it must, otherwise array1[0] would be a System.Object, not a System.Int32.
Given this information, implementing the IList and IEnumerator generics would be relatively easy and quite useful. | | |
Hello
"Kevin P. Fleming" <kp*******@backtobasicsmgmt.com> wrote in message
news:ud*************@TK2MSFTNGP09.phx.gbl... Nicholas Paldino [.NET/C# MVP] wrote:
There just isn't a way for two instances of the same type to implement different interfaces; it breaks way too many OOP rules.
Although int[] and string[] inherit from System.Array, they are not the same
type. System.Array implements the non generic IList, so int[] should
implement IList<int> and string[] should implement IList<string>
Best regards,
Sherif | | |
Hello
Sorry for any inconvenience, but I think people using released version of c#
are intrested in future versions as well.
Best regards,
Sherif
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:#P*************@TK2MSFTNGP09.phx.gbl... Please, post whidbey questions to the private whidbey NG, This NG is for released products.
Willy.
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message news:e9**************@TK2MSFTNGP11.phx.gbl... Hello
I was just got VS 2005 preview, and was trying generics.
I tried the following code
int[] intArray = new int[100]; IList<int> intList = (IList<int>) intArray;
it didn't compile, also the following didn't compile
IEnumerable<int> intEnumerable = (IEnumerable<int>)intArray;
IMHO it makes perfect sense that int[] should implement IList<int>, IEnumerable<int>, etc, since it implements the non-generic IList, and IEnumerable.
Best regards, Sherif
| | |
Thanks
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eC**************@TK2MSFTNGP09.phx.gbl... Sherif,
Given that System.Array implements IList and IEnumerable, the specialized versions should definitely be supported.
I'll file a bug. Thanks for finding it.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com "Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message news:e9**************@TK2MSFTNGP11.phx.gbl... Hello
I was just got VS 2005 preview, and was trying generics.
I tried the following code
int[] intArray = new int[100]; IList<int> intList = (IList<int>) intArray;
it didn't compile, also the following didn't compile
IEnumerable<int> intEnumerable = (IEnumerable<int>)intArray;
IMHO it makes perfect sense that int[] should implement IList<int>, IEnumerable<int>, etc, since it implements the non-generic IList, and IEnumerable.
Best regards, Sherif
| | |
Hi,
Sorry, but I have to disagree,those really interested in future versions can
also subscribe to the private Whidbey NG's., and those actually having
issues with this new stuff, will find better answers in the Whidbey NG's
(MSFT PM are actively monitoring these NG's). And don't forget that we are
talking about pre-alpha code here, nothing is carved in stone yet, some
might really get confused when reading messages about un-released stuff in
public NG's.
Willy.
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message
news:et**************@TK2MSFTNGP11.phx.gbl... Hello
Sorry for any inconvenience, but I think people using released version of c# are intrested in future versions as well.
Best regards, Sherif
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message news:#P*************@TK2MSFTNGP09.phx.gbl... Please, post whidbey questions to the private whidbey NG, This NG is for released products.
Willy.
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message news:e9**************@TK2MSFTNGP11.phx.gbl... > Hello > > I was just got VS 2005 preview, and was trying generics. > > I tried the following code > > int[] intArray = new int[100]; > IList<int> intList = (IList<int>) intArray; > > it didn't compile, also the following didn't compile > > IEnumerable<int> intEnumerable = (IEnumerable<int>)intArray; > > IMHO it makes perfect sense that int[] should implement IList<int>, > IEnumerable<int>, etc, since it implements the non-generic IList, and > IEnumerable. > > Best regards, > Sherif > >
| | |
Hello
I am corrected. Sorry for the inconvenience.
Best regards,
Sherif
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:OV*************@TK2MSFTNGP10.phx.gbl... Hi, Sorry, but I have to disagree,those really interested in future versions
can also subscribe to the private Whidbey NG's., and those actually having issues with this new stuff, will find better answers in the Whidbey NG's (MSFT PM are actively monitoring these NG's). And don't forget that we are talking about pre-alpha code here, nothing is carved in stone yet, some might really get confused when reading messages about un-released stuff in public NG's.
Willy.
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message news:et**************@TK2MSFTNGP11.phx.gbl... Hello
Sorry for any inconvenience, but I think people using released version
of c# are intrested in future versions as well.
Best regards, Sherif
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message news:#P*************@TK2MSFTNGP09.phx.gbl... Please, post whidbey questions to the private whidbey NG, This NG is
for released products.
Willy.
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message news:e9**************@TK2MSFTNGP11.phx.gbl... > Hello > > I was just got VS 2005 preview, and was trying generics. > > I tried the following code > > int[] intArray = new int[100]; > IList<int> intList = (IList<int>) intArray; > > it didn't compile, also the following didn't compile > > IEnumerable<int> intEnumerable = (IEnumerable<int>)intArray; > > IMHO it makes perfect sense that int[] should implement IList<int>, > IEnumerable<int>, etc, since it implements the non-generic IList, and > IEnumerable. > > Best regards, > Sherif > >
| | This discussion thread is closed Replies have been disabled for this discussion. Similar topics
20 posts
views
Thread by Anonymous |
last post: by
|
5 posts
views
Thread by pmatos |
last post: by
|
10 posts
views
Thread by Piotr |
last post: by
|
2 posts
views
Thread by per9000 |
last post: by
|
10 posts
views
Thread by arnuld |
last post: by
|
10 posts
views
Thread by arnuld |
last post: by
| | | | | | | | | | |