custom-type

How can I create an enum using numbers?

Is it possible to make an enum using just numbers in C#? In my program I have a variable, Gain, that can only be set to 1, 2, 4, and 8. I am using a propertygrid control to display and set this value. If I were to create an enum like this... private enum GainValues {One, Two, Four, Eight} and I made my gain variable of type GainValue...

Why custom types accept ad-hoc attributes in Python (and built-ins don't)?

Hi there! I'd like to know why one is able to create a new attribute ("new" means "not previously defined in the class body") for an instance of a custom type, but is not able to do the same for a built-in type, like object itself. A code example: >>> class SomeClass(object): ... pass ... >>> sc = SomeClass() >>> sc.name = "AAA"...

Hiberate mapping type and saved Type

I have Class CustomDate and that is referred in other class called Test. public class CustomDate{ public String toString(){ return "20100829" } } public class Test{ CustomDate date; } In Mapping file of Test <property name="date" COLUMN="DATE"> I want to save only long value and type should be long type and i s...

Custom data type as parameter in WebService

I'm writing a WebService in .NET and use a custom type with no public properties. It looks like this: It is similar to the built-in type Guid but with special validation rules for MAC addresses. The SOAP description looks like this: <StringProperty>string</StringProperty> <GuidProperty>guid</GuidProperty> <MacAddressProperty /> <!--My...