Using xsd.exe I've got an enum which has an @ symbol in front of one of the elements. I can't work out why, and I can't work out what it's for or what it means. Searching Google for a symbol isn't terribly productive.
Original XSD fragment:
<xs:simpleType name="stopLocation">
<xs:restriction base="xs:string">
<xs:enumeration value="default"/>
<xs:enumeration value="near"/>
<xs:enumeration value="far"/>
<xs:enumeration value="nearExact"/>
<xs:enumeration value="farExact"/>
</xs:restriction>
</xs:simpleType>
Generated class fragment:
public enum stopLocation {
@default,
near,
far,
nearExact,
farExact,
}
(Yes, the final element has a comma which VS seems happy with)
Thanks.
It escapes the default keyword from C#.
See this question: What's the use/meaning of the @ character in variable names in C#?
This is happening because the enum value name (default) is a reserved word. In C# reserved words must be appended with an @ so the compiler knows how to interpret them.
You would see the same behavior with a name like 'event' or 'public'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With