From a357bec1831611758a19bf23ff0fa5a5fe99ca52 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sun, 28 May 2023 11:30:53 +0200 Subject: Add changes --- MatrixRoomUtils.Core/Extensions/DictionaryExtensions.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 MatrixRoomUtils.Core/Extensions/DictionaryExtensions.cs (limited to 'MatrixRoomUtils.Core/Extensions') diff --git a/MatrixRoomUtils.Core/Extensions/DictionaryExtensions.cs b/MatrixRoomUtils.Core/Extensions/DictionaryExtensions.cs new file mode 100644 index 0000000..cce71dd --- /dev/null +++ b/MatrixRoomUtils.Core/Extensions/DictionaryExtensions.cs @@ -0,0 +1,15 @@ +namespace MatrixRoomUtils.Core.Extensions; + +public static class DictionaryExtensions +{ + public static bool ChangeKey(this IDictionary dict, + TKey oldKey, TKey newKey) + { + TValue value; + if (!dict.Remove(oldKey, out value)) + return false; + + dict[newKey] = value; // or dict.Add(newKey, value) depending on ur comfort + return true; + } +} \ No newline at end of file -- cgit 1.5.1