[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [DotGNU]A small fix for C# compiler
From: |
Rhys Weatherley |
Subject: |
Re: [DotGNU]A small fix for C# compiler |
Date: |
Sat, 31 Aug 2002 08:14:01 +1000 |
Gopal V wrote:
> I was checking out the foreach loop (in which I had dabbled with
> my dirty hands ...) and caught a segfault . As usual it turned out to
> be my dirty work that caused the segfault ...
>
> char x[]=new char[]{'X','o','X'};
> foreach(int i in x)
> {
> }
>
> Is this legal ? ... I have assumed it is not valid .. So the special
> case of this gives an error message on this line..
It is valid, according to the spec. There must exist an explicit
cast between the element type and the variable type. This allows
one to say
Object[] a;
foreach(String s in a) { ... }
The enumerator returns Object's, and the cast turns them into
strings for the purposes of the loop. I'll let you have another
go at fixing this.
Cheers,
Rhys.