Use generics
public void UpdateEntriesFromAGivenTable<T>(Dictionary<int, T> dictionary, string tableName)
{
foreach (KeyValuePair<int, T> entry in dictionary)
{
Dictionary<string, object> dict = GetTypeNamesAndValuesWithReflection(entry.Value);
foreach (var item in dict)
{
if (item.Value != null && (!string.Equals(item.Key, "id")))
{
UpdateEntry(tableName, item.Key, item.Value, entry.Key);
}
}
}
}
You can call it like
Dictionary<int, User> d = new Dictionary<int, User>();
d.Add(1, new User { Name = "A" });
d.Add(2, new User { Name = "B" });
UpdateEntriesFromAGivenTable(d, "");