Hi Folks,
I've tried to do the following:
public enum AssetType { Requested, InOrder, Received, InPlace, Gone };
(...)
dropAssetType.DataSource = Enum.GetValues(AssetType);
(...)
For some reason this get get compiled, since it says that AssetType is a
class, while a variable is expected,
Any suggestions woulde be appreciated!
Greets,
Gab 6 2256
Hi Gabriël,
Change your code to
dropAssetType.DataSource = Enum.GetValues(typeof(AssetType));
Not exactly sure why just passing AssetType won't work, maybe someone can
clarify.
Happy coding!
Morten Wennevik [C# MVP]
Morten Wennevik <Mo************@hotmail.com> wrote: Change your code to
dropAssetType.DataSource = Enum.GetValues(typeof(AssetType));
Not exactly sure why just passing AssetType won't work, maybe someone can clarify.
Because AssetType isn't an expression - it's the name of a type.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Um, you mean it isn't a type, just a name?
Well, I suppose, since GetValues requires a type, but somehow I would
expect it to work by passing enum name, and have GetValues handle the
typeof cast internally if needed.
Happy coding!
Morten Wennevik [C# MVP]
Morten Wennevik <Mo************@hotmail.com> wrote: Um, you mean it isn't a type, just a name?
Just "AssetType" isn't an expression. typeof(AssetType) is an
expression. AssetType is a type token in terms of the C# language
specification - but it certainly isn't an expression. If you think it's
an expression, what's its value?
Well, I suppose, since GetValues requires a type, but somehow I would expect it to work by passing enum name, and have GetValues handle the typeof cast internally if needed.
typeof isn't a cast - it's an operator.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
But now that the Whidbey compiler lets you specify just a method name
where a delegate is expected (and the compiler figures out the correct
delegate type and adds the instantiation code), you could argue that
you should also be able to specify just a typename in places where a
Type is expected. Just a thought.
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Thanks for all the advices (and explaination, which makes also the why
clear, next tot the how).
Gab
"Mattias Sjögren" <ma********************@mvps.org> schreef in bericht
news:u#**************@TK2MSFTNGP10.phx.gbl... But now that the Whidbey compiler lets you specify just a method name where a delegate is expected (and the compiler figures out the correct delegate type and adds the instantiation code), you could argue that you should also be able to specify just a typename in places where a Type is expected. Just a thought. Mattias
-- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tim Mulholland |
last post by:
I am having a problem where a color i select, and convert to a string for
storage in an XML file is not being converted back properly. The following
is a small example that illustrates the...
|
by: smith |
last post by:
It's a time saver to "bind" .Net enums to list and comboboxes and all the
samples out there seem to use GetNames and GetValues pretty interchangeably.
So I was wondering what the logic is to the...
|
by: thechaosengine |
last post by:
Hi all,
I have a problem that I havent really come accross before.
I need to be able to allow the user to set a dropdown control to a particular
colour value. The permissable values come from...
|
by: Armin Bajramovic |
last post by:
Hi,
I have enum:
public enum StatusEnum
{
Active = 'A',
Nonactive = 'N',
Deleted = 'D'
}
|
by: George |
last post by:
I am trying to check whether a query string is being passed to my .aspx page, like so:
If Not Request.QueryString Is Nothing Then
If CInt(Request.QueryString.GetValues("values")(0)) <> 1 Then...
|
by: Mircea |
last post by:
Hi everybody,
I have a big problem. I am trying to use serial communication in C# 2. The
problem is that the event DataReceived is never fired. I have tried on two
computers and it does not...
|
by: tony |
last post by:
Hello!
I have below a for loop and a switch in the for loop.
I have also a enum called colBlowStep with some values.
I have also an array called m_columnBlowStep with some strings.
All items in...
|
by: Steven Nagy |
last post by:
So I was needing some extra power from my enums and implemented the
typesafe enum pattern.
And it got me to thinking... why should I EVER use standard enums?
There's now a nice little code...
|
by: Jeff Mason |
last post by:
I am observing some puzzling behavior with the GetValues method of enumerations. I
wonder if this something I just don't understand, or is this just wrong.
The documentation for the GetValues...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |