ircsharp/IRCStates/Extensions.cs

23 lines
708 B
C#
Raw Normal View History

2020-05-15 03:06:10 +00:00
using System.Collections.Generic;
using System.Linq;
namespace IRCStates
{
public static class Extensions
{
2020-05-17 02:08:40 +00:00
/// <summary>
/// Update the dictionary with <see cref="other"/>'s keys and values
/// </summary>
/// <param name="dict"></param>
/// <param name="other"></param>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
2020-05-15 03:06:10 +00:00
public static void UpdateWith<TKey, TValue>(this Dictionary<TKey, TValue> dict, Dictionary<TKey, TValue> other)
{
if (dict == null || other == null || !other.Any()) return;
foreach (var (key, value) in other) dict[key] = value;
}
}
}