public CaseInsensitiveComparer(System.Globalization.CultureInfo culture) { }
public static System.Collections.CaseInsensitiveComparer Default { get { throw null; } }
public static System.Collections.CaseInsensitiveComparer DefaultInvariant { get { throw null; } }
- public int Compare(object a, object b) { throw null; }
+ public int Compare(object? a, object? b) { throw null; }
}
[System.ObsoleteAttribute("Please use StringComparer instead.")]
public partial class CaseInsensitiveHashCodeProvider : System.Collections.IHashCodeProvider
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
bool System.Collections.IList.IsReadOnly { get { throw null; } }
- object System.Collections.IList.this[int index] { get { throw null; } set { } }
+ object? System.Collections.IList.this[int index] { get { throw null; } set { } }
public void Clear() { }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
protected virtual void OnClear() { }
protected virtual void OnClearComplete() { }
- protected virtual void OnInsert(int index, object value) { }
- protected virtual void OnInsertComplete(int index, object value) { }
- protected virtual void OnRemove(int index, object value) { }
- protected virtual void OnRemoveComplete(int index, object value) { }
- protected virtual void OnSet(int index, object oldValue, object newValue) { }
- protected virtual void OnSetComplete(int index, object oldValue, object newValue) { }
+ protected virtual void OnInsert(int index, object? value) { }
+ protected virtual void OnInsertComplete(int index, object? value) { }
+ protected virtual void OnRemove(int index, object? value) { }
+ protected virtual void OnRemoveComplete(int index, object? value) { }
+ protected virtual void OnSet(int index, object? oldValue, object? newValue) { }
+ protected virtual void OnSetComplete(int index, object? oldValue, object? newValue) { }
protected virtual void OnValidate(object value) { }
public void RemoveAt(int index) { }
void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
- int System.Collections.IList.Add(object value) { throw null; }
- bool System.Collections.IList.Contains(object value) { throw null; }
- int System.Collections.IList.IndexOf(object value) { throw null; }
- void System.Collections.IList.Insert(int index, object value) { }
- void System.Collections.IList.Remove(object value) { }
+ int System.Collections.IList.Add(object? value) { throw null; }
+ bool System.Collections.IList.Contains(object? value) { throw null; }
+ int System.Collections.IList.IndexOf(object? value) { throw null; }
+ void System.Collections.IList.Insert(int index, object? value) { }
+ void System.Collections.IList.Remove(object? value) { }
}
public abstract partial class DictionaryBase : System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable
{
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IDictionary.IsFixedSize { get { throw null; } }
bool System.Collections.IDictionary.IsReadOnly { get { throw null; } }
- object System.Collections.IDictionary.this[object key] { get { throw null; } set { } }
+ object? System.Collections.IDictionary.this[object key] { get { throw null; } set { } }
System.Collections.ICollection System.Collections.IDictionary.Keys { get { throw null; } }
System.Collections.ICollection System.Collections.IDictionary.Values { get { throw null; } }
public void Clear() { }
public System.Collections.IDictionaryEnumerator GetEnumerator() { throw null; }
protected virtual void OnClear() { }
protected virtual void OnClearComplete() { }
- protected virtual object OnGet(object key, object currentValue) { throw null; }
- protected virtual void OnInsert(object key, object value) { }
- protected virtual void OnInsertComplete(object key, object value) { }
- protected virtual void OnRemove(object key, object value) { }
- protected virtual void OnRemoveComplete(object key, object value) { }
- protected virtual void OnSet(object key, object oldValue, object newValue) { }
- protected virtual void OnSetComplete(object key, object oldValue, object newValue) { }
- protected virtual void OnValidate(object key, object value) { }
- void System.Collections.IDictionary.Add(object key, object value) { }
+ protected virtual object? OnGet(object key, object? currentValue) { throw null; }
+ protected virtual void OnInsert(object key, object? value) { }
+ protected virtual void OnInsertComplete(object key, object? value) { }
+ protected virtual void OnRemove(object key, object? value) { }
+ protected virtual void OnRemoveComplete(object key, object? value) { }
+ protected virtual void OnSet(object key, object? oldValue, object? newValue) { }
+ protected virtual void OnSetComplete(object key, object? oldValue, object? newValue) { }
+ protected virtual void OnValidate(object key, object? value) { }
+ void System.Collections.IDictionary.Add(object key, object? value) { }
bool System.Collections.IDictionary.Contains(object key) { throw null; }
void System.Collections.IDictionary.Remove(object key) { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public virtual object SyncRoot { get { throw null; } }
public virtual void Clear() { }
public virtual object Clone() { throw null; }
- public virtual bool Contains(object obj) { throw null; }
+ public virtual bool Contains(object? obj) { throw null; }
public virtual void CopyTo(System.Array array, int index) { }
- public virtual object Dequeue() { throw null; }
- public virtual void Enqueue(object obj) { }
+ public virtual object? Dequeue() { throw null; }
+ public virtual void Enqueue(object? obj) { }
public virtual System.Collections.IEnumerator GetEnumerator() { throw null; }
- public virtual object Peek() { throw null; }
+ public virtual object? Peek() { throw null; }
public static System.Collections.Queue Synchronized(System.Collections.Queue queue) { throw null; }
- public virtual object[] ToArray() { throw null; }
+ public virtual object?[] ToArray() { throw null; }
public virtual void TrimToSize() { }
}
public abstract partial class ReadOnlyCollectionBase : System.Collections.ICollection, System.Collections.IEnumerable
public partial class SortedList : System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable, System.ICloneable
{
public SortedList() { }
- public SortedList(System.Collections.IComparer comparer) { }
- public SortedList(System.Collections.IComparer comparer, int capacity) { }
+ public SortedList(System.Collections.IComparer? comparer) { }
+ public SortedList(System.Collections.IComparer? comparer, int capacity) { }
public SortedList(System.Collections.IDictionary d) { }
- public SortedList(System.Collections.IDictionary d, System.Collections.IComparer comparer) { }
+ public SortedList(System.Collections.IDictionary d, System.Collections.IComparer? comparer) { }
public SortedList(int initialCapacity) { }
public virtual int Capacity { get { throw null; } set { } }
public virtual int Count { get { throw null; } }
public virtual bool IsFixedSize { get { throw null; } }
public virtual bool IsReadOnly { get { throw null; } }
public virtual bool IsSynchronized { get { throw null; } }
- public virtual object this[object key] { get { throw null; } set { } }
+ public virtual object? this[object key] { get { throw null; } set { } }
public virtual System.Collections.ICollection Keys { get { throw null; } }
public virtual object SyncRoot { get { throw null; } }
public virtual System.Collections.ICollection Values { get { throw null; } }
- public virtual void Add(object key, object value) { }
+ public virtual void Add(object key, object? value) { }
public virtual void Clear() { }
public virtual object Clone() { throw null; }
public virtual bool Contains(object key) { throw null; }
public virtual bool ContainsKey(object key) { throw null; }
- public virtual bool ContainsValue(object value) { throw null; }
+ public virtual bool ContainsValue(object? value) { throw null; }
public virtual void CopyTo(System.Array array, int arrayIndex) { }
- public virtual object GetByIndex(int index) { throw null; }
+ public virtual object? GetByIndex(int index) { throw null; }
public virtual System.Collections.IDictionaryEnumerator GetEnumerator() { throw null; }
public virtual object GetKey(int index) { throw null; }
public virtual System.Collections.IList GetKeyList() { throw null; }
public virtual System.Collections.IList GetValueList() { throw null; }
public virtual int IndexOfKey(object key) { throw null; }
- public virtual int IndexOfValue(object value) { throw null; }
+ public virtual int IndexOfValue(object? value) { throw null; }
public virtual void Remove(object key) { }
public virtual void RemoveAt(int index) { }
- public virtual void SetByIndex(int index, object value) { }
+ public virtual void SetByIndex(int index, object? value) { }
public static System.Collections.SortedList Synchronized(System.Collections.SortedList list) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public virtual void TrimToSize() { }
public virtual object SyncRoot { get { throw null; } }
public virtual void Clear() { }
public virtual object Clone() { throw null; }
- public virtual bool Contains(object obj) { throw null; }
+ public virtual bool Contains(object? obj) { throw null; }
public virtual void CopyTo(System.Array array, int index) { }
public virtual System.Collections.IEnumerator GetEnumerator() { throw null; }
- public virtual object Peek() { throw null; }
- public virtual object Pop() { throw null; }
- public virtual void Push(object obj) { }
+ public virtual object? Peek() { throw null; }
+ public virtual object? Pop() { throw null; }
+ public virtual void Push(object? obj) { }
public static System.Collections.Stack Synchronized(System.Collections.Stack stack) { throw null; }
- public virtual object[] ToArray() { throw null; }
+ public virtual object?[] ToArray() { throw null; }
}
}
namespace System.Collections.Specialized
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>netcoreapp-Debug;netcoreapp-Release;uap-Debug;uap-Release</Configurations>
+ <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Collections.NonGeneric.cs" />
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>System.Collections.NonGeneric</RootNamespace>
<AssemblyName>System.Collections.NonGeneric</AssemblyName>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<Configurations>netcoreapp-Debug;netcoreapp-Release;uap-Windows_NT-Debug;uap-Windows_NT-Release</Configurations>
+ <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Collections\CaseInsensitiveComparer.cs" />
public class CaseInsensitiveComparer : IComparer
{
private readonly CompareInfo _compareInfo;
- private static volatile CaseInsensitiveComparer s_InvariantCaseInsensitiveComparer;
+ private static volatile CaseInsensitiveComparer? s_InvariantCaseInsensitiveComparer;
public CaseInsensitiveComparer()
{
// If a doesn't implement IComparable and b does, -(b.CompareTo(a)) is returned.
// Otherwise an exception is thrown.
//
- public int Compare(object a, object b)
+ public int Compare(object? a, object? b)
{
- string sa = a as string;
- string sb = b as string;
+ string? sa = a as string;
+ string? sb = b as string;
if (sa != null && sb != null)
return _compareInfo.Compare(sa, sb, CompareOptions.IgnoreCase);
else
[Obsolete("Please use StringComparer instead.")]
public class CaseInsensitiveHashCodeProvider : IHashCodeProvider
{
- private static volatile CaseInsensitiveHashCodeProvider s_invariantCaseInsensitiveHashCodeProvider = null;
+ private static volatile CaseInsensitiveHashCodeProvider? s_invariantCaseInsensitiveHashCodeProvider = null;
private readonly CompareInfo _compareInfo;
public CaseInsensitiveHashCodeProvider()
throw new ArgumentNullException(nameof(obj));
}
- string s = obj as string;
+ string? s = obj as string;
return s != null ?
_compareInfo.GetHashCode(s, CompareOptions.IgnoreCase) :
obj.GetHashCode();
{
if (index < 0 || index >= Count)
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
- object temp = InnerList[index];
- OnValidate(temp);
+ object? temp = InnerList[index];
+ OnValidate(temp!);
OnRemove(index, temp);
InnerList.RemoveAt(index);
try
InnerList.CopyTo(array, index);
}
- object IList.this[int index]
+ object? IList.this[int index]
{
get
{
{
if (index < 0 || index >= Count)
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
- OnValidate(value);
- object temp = InnerList[index];
+ OnValidate(value!);
+ object? temp = InnerList[index];
OnSet(index, temp, value);
InnerList[index] = value;
try
}
}
- bool IList.Contains(object value)
+ bool IList.Contains(object? value)
{
return InnerList.Contains(value);
}
- int IList.Add(object value)
+ int IList.Add(object? value)
{
- OnValidate(value);
+ OnValidate(value!);
OnInsert(InnerList.Count, value);
int index = InnerList.Add(value);
try
}
- void IList.Remove(object value)
+ void IList.Remove(object? value)
{
- OnValidate(value);
+ OnValidate(value!);
int index = InnerList.IndexOf(value);
if (index < 0) throw new ArgumentException(SR.Arg_RemoveArgNotFound);
OnRemove(index, value);
}
}
- int IList.IndexOf(object value)
+ int IList.IndexOf(object? value)
{
return InnerList.IndexOf(value);
}
- void IList.Insert(int index, object value)
+ void IList.Insert(int index, object? value)
{
if (index < 0 || index > Count)
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
- OnValidate(value);
+ OnValidate(value!);
OnInsert(index, value);
InnerList.Insert(index, value);
try
return InnerList.GetEnumerator();
}
- protected virtual void OnSet(int index, object oldValue, object newValue)
+ protected virtual void OnSet(int index, object? oldValue, object? newValue)
{
}
- protected virtual void OnInsert(int index, object value)
+ protected virtual void OnInsert(int index, object? value)
{
}
{
}
- protected virtual void OnRemove(int index, object value)
+ protected virtual void OnRemove(int index, object? value)
{
}
if (value == null) throw new ArgumentNullException(nameof(value));
}
- protected virtual void OnSetComplete(int index, object oldValue, object newValue)
+ protected virtual void OnSetComplete(int index, object? oldValue, object? newValue)
{
}
- protected virtual void OnInsertComplete(int index, object value)
+ protected virtual void OnInsertComplete(int index, object? value)
{
}
{
}
- protected virtual void OnRemoveComplete(int index, object value)
+ protected virtual void OnRemoveComplete(int index, object? value)
{
}
}
// Useful base class for typed read/write collections where items derive from object
public abstract class DictionaryBase : IDictionary
{
- private Hashtable _hashtable;
+ private Hashtable? _hashtable;
protected Hashtable InnerHashtable
{
InnerHashtable.CopyTo(array, index);
}
- object IDictionary.this[object key]
+ object? IDictionary.this[object key]
{
get
{
- object currentValue = InnerHashtable[key];
+ object? currentValue = InnerHashtable[key];
OnGet(key, currentValue);
return currentValue;
}
{
OnValidate(key, value);
bool keyExists = true;
- object temp = InnerHashtable[key];
+ object? temp = InnerHashtable[key];
if (temp == null)
{
keyExists = InnerHashtable.Contains(key);
return InnerHashtable.Contains(key);
}
- void IDictionary.Add(object key, object value)
+ void IDictionary.Add(object key, object? value)
{
OnValidate(key, value);
OnInsert(key, value);
{
if (InnerHashtable.Contains(key))
{
- object temp = InnerHashtable[key];
+ object? temp = InnerHashtable[key];
OnValidate(key, temp);
OnRemove(key, temp);
return InnerHashtable.GetEnumerator();
}
- protected virtual object OnGet(object key, object currentValue)
+ protected virtual object? OnGet(object key, object? currentValue)
{
return currentValue;
}
- protected virtual void OnSet(object key, object oldValue, object newValue)
+ protected virtual void OnSet(object key, object? oldValue, object? newValue)
{
}
- protected virtual void OnInsert(object key, object value)
+ protected virtual void OnInsert(object key, object? value)
{
}
{
}
- protected virtual void OnRemove(object key, object value)
+ protected virtual void OnRemove(object key, object? value)
{
}
- protected virtual void OnValidate(object key, object value)
+ protected virtual void OnValidate(object key, object? value)
{
}
- protected virtual void OnSetComplete(object key, object oldValue, object newValue)
+ protected virtual void OnSetComplete(object key, object? oldValue, object? newValue)
{
}
- protected virtual void OnInsertComplete(object key, object value)
+ protected virtual void OnInsertComplete(object key, object? value)
{
}
{
}
- protected virtual void OnRemoveComplete(object key, object value)
+ protected virtual void OnRemoveComplete(object key, object? value)
{
}
}
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class Queue : ICollection, ICloneable
{
- private object[] _array; // Do not rename (binary serialization)
+ private object?[] _array; // Do not rename (binary serialization)
private int _head; // First valid element in the queue. Do not rename (binary serialization)
private int _tail; // Last valid element in the queue. Do not rename (binary serialization)
private int _size; // Number of elements. Do not rename (binary serialization)
// Adds obj to the tail of the queue.
//
- public virtual void Enqueue(object obj)
+ public virtual void Enqueue(object? obj)
{
if (_size == _array.Length)
{
// Removes the object at the head of the queue and returns it. If the queue
// is empty, this method simply returns null.
- public virtual object Dequeue()
+ public virtual object? Dequeue()
{
if (Count == 0)
throw new InvalidOperationException(SR.InvalidOperation_EmptyQueue);
- object removed = _array[_head];
+ object? removed = _array[_head];
_array[_head] = null;
_head = (_head + 1) % _array.Length;
_size--;
// Returns the object at the head of the queue. The object remains in the
// queue. If the queue is empty, this method throws an
// InvalidOperationException.
- public virtual object Peek()
+ public virtual object? Peek()
{
if (Count == 0)
throw new InvalidOperationException(SR.InvalidOperation_EmptyQueue);
// Returns true if the queue contains at least one object equal to obj.
// Equality is determined using obj.Equals().
//
- // Exceptions: ArgumentNullException if obj == null.
- public virtual bool Contains(object obj)
+ public virtual bool Contains(object? obj)
{
int index = _head;
int count = _size;
if (_array[index] == null)
return true;
}
- else if (_array[index] != null && _array[index].Equals(obj))
+ else if (_array[index] != null && _array[index]!.Equals(obj))
{
return true;
}
return false;
}
- internal object GetElement(int i)
+ internal object? GetElement(int i)
{
return _array[(_head + i) % _array.Length];
}
// objects in the Queue, or an empty array if the queue is empty.
// The order of elements in the array is first in to last in, the same
// order produced by successive calls to Dequeue.
- public virtual object[] ToArray()
+ public virtual object?[] ToArray()
{
if (_size == 0)
return Array.Empty<object>();
}
}
- public override bool Contains(object obj)
+ public override bool Contains(object? obj)
{
lock (_root)
{
}
}
- public override void Enqueue(object value)
+ public override void Enqueue(object? value)
{
lock (_root)
{
}
}
- public override object Dequeue()
+ public override object? Dequeue()
{
lock (_root)
{
}
}
- public override object Peek()
+ public override object? Peek()
{
lock (_root)
{
}
}
- public override object[] ToArray()
+ public override object?[] ToArray()
{
lock (_root)
{
private readonly Queue _q;
private int _index;
private readonly int _version;
- private object _currentElement;
+ private object? _currentElement;
internal QueueEnumerator(Queue q)
{
return true;
}
- public virtual object Current
+ public virtual object? Current
{
get
{
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
- public object[] Items
+ public object?[] Items
{
get
{
// Useful base class for typed readonly collections where items derive from object
public abstract class ReadOnlyCollectionBase : ICollection
{
- private ArrayList _list;
+ private ArrayList? _list;
protected ArrayList InnerList
{
public class SortedList : IDictionary, ICloneable
{
private object[] keys; // Do not rename (binary serialization)
- private object[] values; // Do not rename (binary serialization)
+ private object?[] values; // Do not rename (binary serialization)
private int _size; // Do not rename (binary serialization)
private int version; // Do not rename (binary serialization)
private IComparer comparer; // Do not rename (binary serialization)
- private KeyList keyList; // Do not rename (binary serialization)
- private ValueList valueList; // Do not rename (binary serialization)
+ private KeyList? keyList; // Do not rename (binary serialization)
+ private ValueList? valueList; // Do not rename (binary serialization)
// Copy of Array.MaxArrayLength
internal const int MaxArrayLength = 0X7FEFFFFF;
// all entries added to the sorted list.
public SortedList()
{
- Init();
- }
-
- private void Init()
- {
keys = Array.Empty<object>();
values = Array.Empty<object>();
_size = 0;
// interface, which in that case must be implemented by the keys of all
// entries added to the sorted list.
//
- public SortedList(IComparer comparer)
+ public SortedList(IComparer? comparer)
: this()
{
if (comparer != null) this.comparer = comparer;
// the IComparable interface, which in that case must be implemented
// by the keys of all entries added to the sorted list.
//
- public SortedList(IComparer comparer, int capacity)
+ public SortedList(IComparer? comparer, int capacity)
: this(comparer)
{
Capacity = capacity;
// by the keys of all entries in the given dictionary as well as keys
// subsequently added to the sorted list.
//
- public SortedList(IDictionary d, IComparer comparer)
+ public SortedList(IDictionary d, IComparer? comparer)
: this(comparer, (d != null ? d.Count : 0))
{
if (d == null)
// Adds an entry with the given key and value to this sorted list. An
// ArgumentException is thrown if the key is already present in the sorted list.
//
- public virtual void Add(object key, object value)
+ public virtual void Add(object key, object? value)
{
if (key == null) throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
// search and is substantially slower than the Contains
// method.
//
- public virtual bool ContainsValue(object value)
+ public virtual bool ContainsValue(object? value)
{
return IndexOfValue(value) >= 0;
}
// Returns the value of the entry at the given index.
//
- public virtual object GetByIndex(int index)
+ public virtual object? GetByIndex(int index)
{
if (index < 0 || index >= Count)
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
// Returns the value associated with the given key. If an entry with the
// given key is not found, the returned value is null.
//
- public virtual object this[object key]
+ public virtual object? this[object key]
{
get
{
// size of this sorted list. The elements of the list are compared to the
// given value using the Object.Equals method.
//
- public virtual int IndexOfValue(object value)
+ public virtual int IndexOfValue(object? value)
{
return Array.IndexOf(values, value, 0, _size);
}
// Inserts an entry with a given key and value at a given index.
- private void Insert(int index, object key, object value)
+ private void Insert(int index, object key, object? value)
{
if (_size == keys.Length) EnsureCapacity(_size + 1);
if (index < _size)
Array.Copy(keys, index + 1, keys, index, _size - index);
Array.Copy(values, index + 1, values, index, _size - index);
}
- keys[_size] = null;
+ keys[_size] = null!;
values[_size] = null;
version++;
}
// Sets the value at an index to a given value. The previous value of
// the given entry is overwritten.
//
- public virtual void SetByIndex(int index, object value)
+ public virtual void SetByIndex(int index, object? value)
{
if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
values[index] = value;
get { return true; }
}
- public override object this[object key]
+ public override object? this[object key]
{
get
{
}
}
- public override void Add(object key, object value)
+ public override void Add(object key, object? value)
{
lock (_root)
{
}
}
- public override bool ContainsValue(object key)
+ public override bool ContainsValue(object? key)
{
lock (_root)
{
}
}
- public override object GetByIndex(int index)
+ public override object? GetByIndex(int index)
{
lock (_root)
{
}
}
- public override int IndexOfValue(object value)
+ public override int IndexOfValue(object? value)
{
lock (_root)
{
}
}
- public override void SetByIndex(int index, object value)
+ public override void SetByIndex(int index, object? value)
{
lock (_root)
{
private class SortedListEnumerator : IDictionaryEnumerator, ICloneable
{
private readonly SortedList _sortedList;
- private object _key;
- private object _value;
+ private object _key = null!;
+ private object? _value;
private int _index;
private readonly int _startIndex; // Store for Reset.
private readonly int _endIndex;
_current = true;
return true;
}
- _key = null;
+ _key = null!;
_value = null;
_current = false;
return false;
}
}
- public virtual object Current
+ public virtual object? Current
{
get
{
}
}
- public virtual object Value
+ public virtual object? Value
{
get
{
if (_version != _sortedList.version) throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
_index = _startIndex;
_current = false;
- _key = null;
+ _key = null!;
_value = null;
}
}
get { return sortedList.SyncRoot; }
}
- public virtual int Add(object key)
+ public virtual int Add(object? key)
{
throw new NotSupportedException(SR.NotSupported_SortedListNestedWrite);
// return 0; // suppress compiler warning
throw new NotSupportedException(SR.NotSupported_SortedListNestedWrite);
}
- public virtual bool Contains(object key)
+ public virtual bool Contains(object? key)
{
- return sortedList.Contains(key);
+ return sortedList.Contains(key!);
}
public virtual void CopyTo(Array array, int arrayIndex)
throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, nameof(array));
// defer error checking to Array.Copy
- Array.Copy(sortedList.keys, 0, array, arrayIndex, sortedList.Count);
+ Array.Copy(sortedList.keys, 0, array!, arrayIndex, sortedList.Count);
}
- public virtual void Insert(int index, object value)
+ public virtual void Insert(int index, object? value)
{
throw new NotSupportedException(SR.NotSupported_SortedListNestedWrite);
}
- public virtual object this[int index]
+ public virtual object? this[int index]
{
get
{
return new SortedListEnumerator(sortedList, 0, sortedList.Count, SortedListEnumerator.Keys);
}
- public virtual int IndexOf(object key)
+ public virtual int IndexOf(object? key)
{
if (key == null)
throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
return -1;
}
- public virtual void Remove(object key)
+ public virtual void Remove(object? key)
{
throw new NotSupportedException(SR.NotSupported_SortedListNestedWrite);
}
get { return sortedList.SyncRoot; }
}
- public virtual int Add(object key)
+ public virtual int Add(object? key)
{
throw new NotSupportedException(SR.NotSupported_SortedListNestedWrite);
}
throw new NotSupportedException(SR.NotSupported_SortedListNestedWrite);
}
- public virtual bool Contains(object value)
+ public virtual bool Contains(object? value)
{
return sortedList.ContainsValue(value);
}
throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, nameof(array));
// defer error checking to Array.Copy
- Array.Copy(sortedList.values, 0, array, arrayIndex, sortedList.Count);
+ Array.Copy(sortedList.values, 0, array!, arrayIndex, sortedList.Count);
}
- public virtual void Insert(int index, object value)
+ public virtual void Insert(int index, object? value)
{
throw new NotSupportedException(SR.NotSupported_SortedListNestedWrite);
}
- public virtual object this[int index]
+ public virtual object? this[int index]
{
get
{
return new SortedListEnumerator(sortedList, 0, sortedList.Count, SortedListEnumerator.Values);
}
- public virtual int IndexOf(object value)
+ public virtual int IndexOf(object? value)
{
return Array.IndexOf(sortedList.values, value, 0, sortedList.Count);
}
- public virtual void Remove(object value)
+ public virtual void Remove(object? value)
{
throw new NotSupportedException(SR.NotSupported_SortedListNestedWrite);
}
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class Stack : ICollection, ICloneable
{
- private object[] _array; // Storage for stack elements. Do not rename (binary serialization)
+ private object?[] _array; // Storage for stack elements. Do not rename (binary serialization)
private int _size; // Number of items in the stack. Do not rename (binary serialization)
private int _version; // Used to keep enumerator in sync w/ collection. Do not rename (binary serialization)
return s;
}
- public virtual bool Contains(object obj)
+ public virtual bool Contains(object? obj)
{
int count = _size;
if (_array[count] == null)
return true;
}
- else if (_array[count] != null && _array[count].Equals(obj))
+ else if (_array[count] != null && _array[count]!.Equals(obj))
{
return true;
}
throw new ArgumentException(SR.Argument_InvalidOffLen);
int i = 0;
- object[] objArray = array as object[];
+ object?[]? objArray = array as object[];
if (objArray != null)
{
while (i < _size)
// Returns the top object on the stack without removing it. If the stack
// is empty, Peek throws an InvalidOperationException.
- public virtual object Peek()
+ public virtual object? Peek()
{
if (_size == 0)
throw new InvalidOperationException(SR.InvalidOperation_EmptyStack);
// Pops an item from the top of the stack. If the stack is empty, Pop
// throws an InvalidOperationException.
- public virtual object Pop()
+ public virtual object? Pop()
{
if (_size == 0)
throw new InvalidOperationException(SR.InvalidOperation_EmptyStack);
_version++;
- object obj = _array[--_size];
+ object? obj = _array[--_size];
_array[_size] = null; // Free memory quicker.
return obj;
}
// Pushes an item to the top of the stack.
//
- public virtual void Push(object obj)
+ public virtual void Push(object? obj)
{
if (_size == _array.Length)
{
// Copies the Stack to an array, in the same order Pop would return the items.
- public virtual object[] ToArray()
+ public virtual object?[] ToArray()
{
if (_size == 0)
return Array.Empty<object>();
- object[] objArray = new object[_size];
+ object?[] objArray = new object[_size];
int i = 0;
while (i < _size)
{
}
}
- public override bool Contains(object obj)
+ public override bool Contains(object? obj)
{
lock (_root)
{
}
}
- public override void Push(object value)
+ public override void Push(object? value)
{
lock (_root)
{
}
}
- public override object Pop()
+ public override object? Pop()
{
lock (_root)
{
}
}
- public override object Peek()
+ public override object? Peek()
{
lock (_root)
{
}
}
- public override object[] ToArray()
+ public override object?[] ToArray()
{
lock (_root)
{
private readonly Stack _stack;
private int _index;
private readonly int _version;
- private object _currentElement;
+ private object? _currentElement;
internal StackEnumerator(Stack stack)
{
return retval;
}
- public virtual object Current
+ public virtual object? Current
{
get
{
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
- public object[] Items
+ public object?[] Items
{
get
{