Re: [Quickfix-developers] Non-const constants
Brought to you by:
orenmnero
From: Jonathan A. <ja...@aa...> - 2008-06-26 18:37:39
|
Well that's certainly a stupid limitation on C#'s part. And since "just use VB" probably isn't the answer you are looking for, I'm behind you on this one. Looking through the object model, it looks like there are a lot of other places where making that change would also be beneficial. For example, it looks like all the field enumerations use that instead of constants. Jonathan Louis Allen Software Developer D: 858.547.7731 C: 619.933.8527 Advisors Asset Management 7220 Trade Street Suite 310 San Diego, CA 92121 www.aam.us.com ________________________________ From: qui...@li... [mailto:qui...@li...] On Behalf Of Brian Erst Sent: Thursday, June 26, 2008 9:32 AM To: qui...@li... Subject: [Quickfix-developers] Non-const constants Is there are a reason that constant strings in the .Net library are not "const"? For instance, the MsgType class defines a whole series of static string "constants" for all the known FIX message types (beginning with ALLOCATION and ending with XML_MESSAGE). Unfortunately, they are defined as "public static string" rather than "public const string". This may seem like a trivial difference, but it means that these values can't be used as part of a switch() statement. switch (msgType.getValue()) { case MsgType.HEARTBEAT: // Doesn't work - not a constant value } So, I end up making parallel classes that simply redefine the values in a "const" manner. public class MsgTypeConstants { public const string HEARTBEAT = "0"; ... } switch (msgType.getValue()) { case MsgTypeConstants.HEARTBEAT: // This works } Is there a reason for "static" instead of "const"? - Brian Erst Thynk Software, Inc. Advisors Asset Management, Inc. (AAM) is a FINRA/ SIPC member and SEC Registered Investment Advisor. INFORMATION REGARDING SECURITIES IS FOR BROKER/DEALER AND REGISTERED ADVISOR USE ONLY - NOT FOR USE WITH THE PUBLIC If the reader of this message is not the intended recipient, you are notified that any disclosure, distribution or copying is prohibited. Please see http://www.aam.us.com/FISBonds/PublicSite/EmailDisclosures.aspx for additional disclosures. |