Hi Folks,
I've tried to do the following:
public enum AssetType { Requested, InOrder, Received, InPlace, Gone };
(...)
dropAssetType.D ataSource = 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 2273
Hi Gabriël,
Change your code to
dropAssetType.D ataSource = Enum.GetValues( typeof(AssetTyp e));
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.D ataSource = Enum.GetValues( typeof(AssetTyp e));
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.co m> 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(AssetTyp e) 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.co m> 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.o rg> schreef in bericht
news:u#******** ******@TK2MSFTN GP10.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 problem.The color seems to show up
properly, but it has lost its IsNamedColor property. Is it possible to get
this back or is there any different way i should be doing any of this?
string s = System.Drawing.SystemColors.Control.ToArgb().ToString();...
|
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 System.Drawing.RotateFlipType
enumeration.
GetNames and GetValues results don't seem to synch up and binding to
GetValues seems to create duplicates of some elements while"losing" others,
and I haven't seen any mention of why that might be.
|
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 the Color enumeration and
unfortunately I can't change this implementation detail.
My question is, how can I load the values into the dropdown using the enumeration,
and more importantly, when a user selects an entry in the dropdown, how do
|
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
Response.Redirect("../somepage.htm")
End If
Else
Response.Redirect("../somepage.htm")
End If
| |
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 work at all. I have tried also in C++ .NET 2005 and
also does not work.
I did not find any useful information on the net.
Do you have a small working C# program about how to setup and use the COM1
|
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 the array m_columnBlowStep is string because I have used
ToString on each enum item as you can see.
I want to use enum in the case statment in the switch.
I know I can use string but I rather want to use enum.
|
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 snippet that I wrote today that gives me
an instant implementation of the pattern. I could easily just always
use such an implementation instead of a standard enum, so I wanted to
know what you experts all thought.
Is there a case for standard enums?
|
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 method says "The elements of the array
are sorted by the values of the enumeration constants". Further the docs state that
absent any underlying type definition of the enumeration, the type is assumed to be
int32 (a signed integer).
Consider the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |