Fix T[]->ArraySegment cast to return default for null (#16301)
authorStephen Toub <stoub@microsoft.com>
Fri, 9 Feb 2018 20:31:22 +0000 (15:31 -0500)
committerJan Kotas <jkotas@microsoft.com>
Fri, 9 Feb 2018 20:31:22 +0000 (12:31 -0800)
src/mscorlib/shared/System/ArraySegment.cs

index d45fb0d..3a13595 100644 (file)
@@ -192,7 +192,7 @@ namespace System
             return !(a == b);
         }
 
-        public static implicit operator ArraySegment<T>(T[] array) => new ArraySegment<T>(array);
+        public static implicit operator ArraySegment<T>(T[] array) => array != null ? new ArraySegment<T>(array) : default;
 
         #region IList<T>
         T IList<T>.this[int index]