473,397 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

C# version of VB.NET "AddRange" method w/generic collection

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.Collections.Generic.List (Of
System.Drawing.KnownColor)
clrs.AddRange(System.Enum.GetValues (enClr.GetType()))

I translated this to:

System.Drawing.KnownColor enClr;
System.Collections.Generic.List<System.Drawing.Kno wnColorclrs =
new System.Collections.Generic.List<System.Drawing.Kno wnColor>();
clrs.AddRange(System.Enum.GetValues(enClr.GetType( )));

But get error on line 3:

"Argument '1': cannot convert from 'System.Array' to
'System.Collections.Generic.IEnumerable<System.Dra wing.KnownColor>'"

In the debugger it sure looks likes like
"System.Enum.GetValues(enClr.GetType())" 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
Apr 7 '08 #1
1 1987
Martin:

That was it. Thanks very much!

And thanks for such a rapid reply. I hope the question wasn't too
rudimentary. - Dave

Apr 7 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered...
1
by: fl | last post by:
I am running ASPNET on my local machine. I have a problem when I try to connect to a SQL server database table. The data looks good when I right click SqlDataAdapter1 to preview the data. When F5...
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
1
by: Robin Tucker | last post by:
Hi, I have a problem with my code (somewhere in the InitialiseComponent) preventing any of my controls being visible in form design mode, although everything is ok at runtime. No errors are...
1
by: renor321 | last post by:
Hello, I've searched the groups unsuccessfully to the solution to this problem. I've seen a few others making note of it, but it didn't seem like there were any solutions. I have a drop down...
2
by: ashishjainism | last post by:
I am unable to install my windows service and the installutil is throwing the following error: Running a transacted installation. Beginning the Install phase of the installation. See the...
8
by: t f | last post by:
Hi I have some code which does basically the following: void A() { ArrayList al1 = new ArrayList(); al1.AddRange(GetSomeNames()); //do something with al1... }
1
by: Grok | last post by:
Is this a feature of ListBox that when using a DataSource, the SelectedItem acts different? Added ListBox1 and ListBox2 to a form. ListBox1 is bound to a DataSource where DisplayedMember=name...
7
by: Spam Catcher | last post by:
Is it possible to change the autocomplete behaviour to search for the word instead of just checking for the prefix? For example, if I have the following items: Big Mac Quarter Pounder...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.