I suggest you ...

inline anonymous enum

I would to use inline anonymous enums with C#
For example instead writing:

public class PutPaySheetRequest
{
public PutPaySheetMode Mode { get; set; }
public enum PutPaySheetMode { Live, Test };
}

I would write:

public class PutPaySheetRequest
{
public enum {Live,Test} Mode { get; set; }
}

4 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    MaxMax shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • qstreamqstream commented  ·   ·  Flag as inappropriate

        This way, how we can compare the property value with some value from this enum? and how to declare it in method params?
        Do you have any idea?

        public class PutPaySheetRequest
        {
        public enum {Live,Test} Mode { get; set; }
        public void Test2(mode??){}//object? int?
        public void Test1(){
        //how to say this?
        var newMode = Live;//?? how to say this?
        if(Mode == newMode) {}
        }

      Feedback and Knowledge Base