Friends:
I'm an ex-VB programmer with a new job in an all C# shop. No problems
the past few months thinking/converting between the two, but I just
ran into a problem translating some working VB code from C#:
Dim enClr As System.Drawing. KnownColor
Dim clrs As New System.Collecti ons.Generic.Lis t (Of
System.Drawing. KnownColor)
clrs.AddRange(S ystem.Enum.GetV alues (enClr.GetType( )))
I translated this to:
System.Drawing. KnownColor enClr;
System.Collecti ons.Generic.Lis t<System.Drawin g.KnownColorclr s =
new System.Collecti ons.Generic.Lis t<System.Drawin g.KnownColor>() ;
clrs.AddRange(S ystem.Enum.GetV alues(enClr.Get Type()));
But get error on line 3:
"Argument '1': cannot convert from 'System.Array' to
'System.Collect ions.Generic.IE numerable<Syste m.Drawing.Known Color>'"
In the debugger it sure looks likes like
"System.Enum.Ge tValues(enClr.G etType())" is indeed returning a list of
type <System.Drawing .KnownColor>. I even ran the code thru a public
VB.NET to C# converter to see if I was missing anything, it gave me
exactly the same translation.
Can anyone see what I'm missing?
Thanks. - Dave
I'm an ex-VB programmer with a new job in an all C# shop. No problems
the past few months thinking/converting between the two, but I just
ran into a problem translating some working VB code from C#:
Dim enClr As System.Drawing. KnownColor
Dim clrs As New System.Collecti ons.Generic.Lis t (Of
System.Drawing. KnownColor)
clrs.AddRange(S ystem.Enum.GetV alues (enClr.GetType( )))
I translated this to:
System.Drawing. KnownColor enClr;
System.Collecti ons.Generic.Lis t<System.Drawin g.KnownColorclr s =
new System.Collecti ons.Generic.Lis t<System.Drawin g.KnownColor>() ;
clrs.AddRange(S ystem.Enum.GetV alues(enClr.Get Type()));
But get error on line 3:
"Argument '1': cannot convert from 'System.Array' to
'System.Collect ions.Generic.IE numerable<Syste m.Drawing.Known Color>'"
In the debugger it sure looks likes like
"System.Enum.Ge tValues(enClr.G etType())" is indeed returning a list of
type <System.Drawing .KnownColor>. I even ran the code thru a public
VB.NET to C# converter to see if I was missing anything, it gave me
exactly the same translation.
Can anyone see what I'm missing?
Thanks. - Dave
Comment