Does an Enum exist for Asc or Desc ordering?

前端 未结 5 634
后悔当初
后悔当初 2021-02-03 17:53

Is there an Enum natively in .NET for asceding or Desceding ordering?

I need to use the ordering concept in different libraries, and I want loose coupling as possible.

5条回答
  •  旧时难觅i
    2021-02-03 18:25

    Interesting point relating to Windows.Forms.SortOrder and Data.SqlClient.SortOrder

    Upon inspection the first has values:

    public enum SortOrder
    {
        None = 0,
        Ascending = 1,
        Descending = 2,
    }
    

    while the second has values:

    public enum SortOrder
    {
        Unspecified = -1,
        Ascending = 0,
        Descending = 1,
    }
    

    Probably a good idea to be consistent, especially if serialising.

提交回复
热议问题