Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Enum Issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Custom Enum Issue

    Hello all,
    I am trying to create a enum as a user input to allow the user to select an option which would switch an integer value. The below code prints "1", regardless of which value (NQ or ES) is selected. I'm not sure where I have it wrong here.

    Code:
    switch (asset)
    {
          case AssetName.ES:
          {
                x = 1;
                break;
          }
          case AssetName.NQ:
          {
                x = 2;
                break;
          }​
    }
    
    Print(x);
    Code:
    [Display(Name = "Ticker", GroupName="Inputs")]
    public AssetName Asset
    {
          get { return asset; }
          set { asset = asset; }
    }​
    Code:
    public enum AssetName
    {
        ES,
        NQ
    }​

    #2
    Code:
    [Display(Name = "Ticker", GroupName="Inputs")]
    public AssetName Asset
    {
        get { return asset; }
        set { asset = value; }
    }
    You had,

    asset = asset;

    It should be,

    asset = value;

    -=o=-

    Or you could do this,

    [Display(Name = "Ticker", GroupName="Inputs")]
    public AssetName Asset { get; set; }


    and then use uppercase 'Asset' property everywhere you're
    currently using the lowercase 'asset' variable. Then delete
    the lowercase 'asset' variable, since it's no longer being used.

    Last edited by bltdavid; 05-30-2023, 10:17 PM.

    Comment


      #3
      ahhh, that makes sense. The second option is perfect. Thanks David.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      63 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      90 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      47 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      105 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      63 views
      0 likes
      Last Post PaulMohn  
      Working...
      X