Hello, @x13xxxswatxxx
We truly appreciate your comment and we strive to improve your experience in docs.microsoft.com. However, we need more information in order to be able to address your feedback. Can you please provide more detailed information and clarify your comment?
Kind regards,
Microsoft DOCS International Team
_HTTPError.Append(new KeyValuePair<int, string>(2000, "Fail line!"));
Console.WriteLine(_HTTPError[2000]);
System.Collections.Generic.KeyNotFoundException: "The given key '2000' was not present in the dictionary."
Append method returns a new sequence
Dictionary<int, string> _HTTPError = new Dictionary<int, string>()
{
[400] = "Bad Request",
[401] = "Unauthorized"
}
var _new = _HTTPError.Append(new KeyValuePair<int, string>(2000, "Fail line!"));
Console.WriteLine(_new[2000]);
It work
This method does not modify the elements of the collection. Instead, it creates a copy of the collection with the new element.
I don't think any changes should be made to Dictionary article. But it might be useful to reword Append method summary a little. Such as Returns a new sequence, produced by appending a value to the end of the source sequence.
I'm talking about this. On this page, in the English version, there is no this method, but there is a Russian one. What is misleading. You can also get confused in any of the links Microsoft Docs. They intersect with each other, from easy to complex, in different languages. One word trash.
@x13xxxswatxxx commented on Sat May 18 2019
public static System.Collections.Generic.Comparer<T> Create (Comparison<T> comparison);
Сведения о документе
⚠ Не вносите правки в этот раздел. Это необходимо для связывания страницы сайта docs.microsoft.com с вопросом на GitHub.
@CeciAc commented on Tue May 21 2019
Hello, @x13xxxswatxxx We truly appreciate your comment and we strive to improve your experience in docs.microsoft.com. However, we need more information in order to be able to address your feedback. Can you please provide more detailed information and clarify your comment? Kind regards, Microsoft DOCS International Team
@x13xxxswatxxx commented on Wed May 22 2019
https://docs.microsoft.com/ru-ru/dotnet/api/system.collections.generic.dictionary-2.keycollection?view=netframework-4.8 Extension Methods in rus version Append(IEnumerable, TSource) - Добавляет значение в конец последовательности. (Adds a value to the end of the sequence.)
My example: don't Adds a value to the end of the sequence
Dictionary<int, string> _HTTPError = new Dictionary<int, string>()
{
[400] = "Bad Request",
[401] = "Unauthorized"
}
_HTTPError.Append(new KeyValuePair<int, string>(2000, "Fail line!")); Console.WriteLine(_HTTPError[2000]); System.Collections.Generic.KeyNotFoundException: "The given key '2000' was not present in the dictionary." Append method returns a new sequence Dictionary<int, string> _HTTPError = new Dictionary<int, string>() { [400] = "Bad Request", [401] = "Unauthorized" }
var _new = _HTTPError.Append(new KeyValuePair<int, string>(2000, "Fail line!")); Console.WriteLine(_new[2000]); It work
@MSDN-WhiteKnight commented on Wed May 22 2019
Append method is not a part of Dictionary class, it's an extension method of IEnumerable. This aspect is covered in detail in its article: https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.append?view=netframework-4.8#remarks
I don't think any changes should be made to Dictionary article. But it might be useful to reword Append method summary a little. Such as Returns a new sequence, produced by appending a value to the end of the source sequence.
@x13xxxswatxxx commented on Wed May 22 2019
I'm talking about this. On this page, in the English version, there is no this method, but there is a Russian one. What is misleading. You can also get confused in any of the links Microsoft Docs. They intersect with each other, from easy to complex, in different languages. One word trash.