Is it possible to cast a variable of type: dictionary<int, models.user> to dictionary<int, object> in C#?
Hi, everyone. I am working on a c# application where I have about 15 methods that Update entries in the database. So I want to make one method for update with two parameters: Dictionary<int, object> dictionary and
string tableName. The 'object' part of the dictionary will accept different ViewModels. Here is my code:
But when I tried to use the above method, I receive the red underline below the parameter "Dictionary<int, user>" and the error message is: cannot convert from 'System.Collections.Generic.Dictionary<int, Models.User> to 'System.Collections.Generic.Dictionary<int, object>.
What I have tried:
I tried the following cast:
(Dictionary<int, object>)(users)
but without success. I looked for help in google and stackoverflow but did not find a similar issue. So can you tell me is it possible to cast a variable of Type: Dictionary<int, Models.User> to Dictionary<int, object> and if the answer is yes, how to do it? Thanks.