C# switch中(case 条件:) 条件判断


class BinaryTree<T>
        // where T:IComparable<T>
        {
            public BinaryTree(T item)
            {
                Item = item;
            }
            public T Item { get; set; }
            public Pair<BinaryTree<T>> SubItem
            {
                get { return _SubItem; }
                set
                {
                    //IComparable<T> first;
                    //first = value.First.Item;

                    switch (value)
                    {
                        case { First: null }:
                            break;
                        case { Second: null }:
                            break;
                        case
                        {
                            First: { Item: IComparable<T> first },// First: { Item: T first },带接口约束
                            Second: { Item: T second }
                        }:
                            if (first.CompareTo(second) < 0)
                            {
                                Console.WriteLine("first is less than second");
                                // first is less than second
                            }
                            else
                            {
                                Console.WriteLine("second is less than or equal to first");
                                // second is less than or equal to first
                            }
                            break;
                        default:
                            throw new InvalidCastException(
                                @$"Unable to sort the items as {typeof(T)} does not support IComparable<T>.");
                    }
                    _SubItem = value;
                }

            }
            private Pair<BinaryTree<T>> _SubItem;
        }
class Pair<T>
        {
            public Pair(T first, T second)
            {
                First = first;
                Second = second;
            }

            public T First { get; set; }
            public T Second { get; set; }
        }

想询问BinaryTree中switch语句中case中的{First:null}是什么意思,是First is null?的意思吗?First: { Item: IComparable first }是什么意思?

.NET 版本是多少