You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
629 B

3 years ago
using System.Collections.Generic;
namespace EC.App.Entity.Base
{
public class DictBase<K, V>
{
private Dictionary<K, V> Dict { get; } = new();
public DictBase()
{ }
#region Operate
public bool TryAdd(K key, V value)
{
return Dict.TryAdd(key, value);
}
public bool Remove(K key)
{
return Dict.Remove(key);
}
public bool TryUpdate(K key, V value)
{
Remove(key);
return TryAdd(key, value);
}
public bool TryGet(K key, out V value)
{
return Dict.TryGetValue(key, out value);
}
public bool IsExist(K key)
{
return Dict.ContainsKey(key);
}
#endregion Operate
}
}