I'm not very used to programming with flags, but I think I just found a situation where they'd be useful:
I've got a couple of objects that register themselves as listeners to certain events. What events they register for is dependent on a variable that is sent to them when they are constructed. I think a nice way to do this would be to...
How do I map an enum with a field in it?
public enum MyEnum{
HIGHSCHOOL ("H"), COLLEGE("C")
private int value;
public MyEnum getInstance(String value){...}
}
@Entity
public class MyEntity {
@Enumerated(...)
private MyEnum eduType;
}
How do I annotate so that values H, C will be persisted in the database? If I keep @Enumerated(EnumTyp...
Hi
Im extending the UIButton Class to be able to set the font and color of the UINavigationBarButton ( from this code example: switch on the code )
I goes like this:
@interface NavBarButtonGrey : UIButton
-(id)init;
@end
@implementation NavBarButtonGrey
-(id)init {
if(self = [super init]) {
self.frame = CGRectMake(0, 0, 49.0,...
(OK, I'll expose the depths of my ignorance here, please be gentle)
Background
I've got a method which looks (a bit) like this:
public void AddLink(Enum enumVal)
{
string identifier = m_EnumInterpreter(enumVal);
AddLink(identifier);
}
The EnumInterpreter is a Func<Enum, string> that is passed in when the parent class is cr...
Hi,
I was wondering whether or not I can extend the Enum type in C# to implement my custom Enum.GetValues(type) and call it like Enum.GetMyCustomValues(type)
I am trying to implement something like this:
public static bool IsFlagSet<T>(this T value, T flag) where T : Enum
{
return (value & flag) != (T)0;
}
but it cannot be done....
Hi all,
I recently created a class which has a constructor taking 3 enumerations as arguments. These enumerations are defined in the object itself as ObjectEnum and AnotherObjectEnum in the example below.
LongObjectName pt = new LongObjectName(
LongObjectName.ObjectEnum.EnumerationOne,
LongObjectName.ObjectEnum....
How do I access an enum that is defined within a COM interface? Specifically, I've created a new instance of an iTunes.Application:
var iTunesApp = WScript.CreateObject("iTunes.Application");
... and I want to be able to use certain enums defined within the COM
iTunesTrackCOM.idl File Reference
[...]
Enumerations
[...]
...
I have bound a flagged enum to a bunch of checkboxes by using a value converter that works as described in the solution to this question. This works fine when I'm working with a flag that hasn't been set to anything.
However, in the non-trivial use case that the flag is actually set to some data, on load the checkboxes are bound correct...
If I have the following WSDL method
−
−
and "EnumeratedIdentifier" is a C# enumerated type, how can I make a service call to this method in a PHP client, since PHP is loosely typed? Thanks in advance.
...
I'm getting the following error when I'm trying to install webrat in my OS X, please suggest me how can i solve this problem.
ERROR:
Error installing webrat:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Li...
duplicate of http://stackoverflow.com/questions/1659586/error-in-webrat-installation
hai all,
i am getting an error when i am iinstalling webrat for my rails app.i want to use in my rails app cucumber, rspec,webrat to my app test.so please give me some solution to this error.
ERROR: Error installing webrat:
ERROR: Failed ...
Founded that:
typeof(System.Enum).IsClass == false
It's become strange that System.Enum has also .IsValueType == false, but Reflector shows that it is really just an abstract class.
System.Enum is a reference type like a System.ValueType and casting enumeration values to/from System.Enum reference caused boxing/unboxing. No surprises...
If I have an enum that's marked with [Flags], is there a way in .NET to test a value of this type to see if it only contains a single value? I can get the result I want using bit-counting, but I'd rather use built-in functions if possible.
When looping through the enum values dynamically, Enum.GetValues() returns the combination flags a...
Is it possible to loop through enum values in Objective-C?
...
I have a situation where I'm receiving an enum from an external system, and for which I need to return an enum of our own. The two enums have the exact same literal values in them:
// externalEnum is guaranteed not to be null
public static MyEnum enumToEnum(final Enum<? extends Enum<?>> externalEnum)
{
if( externalEnum instanceof M...
How come this code doesnt compile?
class A
{
class B
{
public enum Enum <-- this line
{
AD,
BC
}
}
}
Compiler reports:
enum declarations allowed only in static contexts.
But then when I put the Enum inside class A, everything is okay.
This is quite surprising. I dont think I have this problem in C++...
I have a class that defines its own enum like this:
public class Test
{
enum MyEnum{E1, E2};
public static void aTestMethod() {
Test2(E1); // << Gives "E1 cannot be resolved" in eclipse.
}
public Test2(MyEnum e) {}
}
If I specify MyEnum.E1 it works fine, but I'd really just like to have it as "E1". Any idea ...
I have this code:
public enum StateId { NotSet = 0, AL, ..., WY }
public class EnumBasedArray<I,V>:IEnumerable<V>
{
public V this[I index]
{
get { return _data[index]; }
set { _data[index] = value; }
}
// other code to manage values internally
}
public class AnotherObject { ... }
public class ArrayOfAnotherObjectByS...
Hi i want to use an enum in postgresql as an alternative to making a table, because the values my never change, but i want to be able to retrieve these values for an application that might check just in case they do, is there any way the query it to get the values?
...
I might be going in the wrong direction, so let me try to sort out my thoughts (and hopefully get some tips from you guys):
Imagine an enum:
public enum ReportType
{
Performance,
Trending,
Statistical
}
This enum will also be a property or paramter to the constructor of a form. The value of the ReportType will determine thi...