Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Redundant type repetition in comparison expressions #4582

Closed
biqas opened this issue Aug 16, 2015 · 2 comments
Closed

Proposal: Redundant type repetition in comparison expressions #4582

biqas opened this issue Aug 16, 2015 · 2 comments

Comments

@biqas
Copy link

biqas commented Aug 16, 2015

A proposal for reducing redundancy in comparison expressions.

public enum MyEnum : int
{
    A = 1,
    B = 2,
    C = 3
}

var x = MyEnum.C;

if (x == MyEnum.A || x == MyEnum.B)

into

if (x == (MyEnum.A || MyEnum.B))

or

if (x == { MyEnum.A || MyEnum.B })

or

if (x == MyEnum.{ A || B })

if ((int)x == { 1 || 2 })

// leave the cast, because the enum is extending int
if (x == { 1 || 2 })
@HaloFour
Copy link

Duplicate of #136.

@biqas
Copy link
Author

biqas commented Aug 16, 2015

@HaloFour
Was not aware of this thx.

@biqas biqas closed this as completed Aug 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants