R
RichB
Something I don't understand why it is happening, or how to fix it.....
I have a teacher class which inherits from person.
And within a search class have a search method with the following:
Dictionary<String, Person> people = new Dictionary<String, Person>();
people.Add("a", new Teacher("Bob", "Smith");
Teacher teach;
if (!people.TryGetValue("Jane", out teach)
{
teach = new Teacher ("Jane", "Jones");
}
Error 1 The best overloaded method match for
'System.Collections.Generic.Dictionary<string,DataTier.VOs.VO>.TryGetValue(string,
out DataTier.VOs.VO)' has some invalid arguments C:\Documents and
Settings\Richard Box\My Documents\Visual Studio
2005\Projects\DataTier\DataTier\DataAccess\EventDAO.cs 307 26 DataTier
Error 2 Argument '2': cannot convert from 'out DataTier.VOs.EventVO' to 'out
DataTier.VOs.VO' C:\Documents and Settings\Richard Box\My Documents\Visual
Studio 2005\Projects\DataTier\DataTier\DataAccess\EventDAO.cs 307 57
DataTier
But Teacher is a Person, so why can an implicit conversion not be performed?
Is there a way around this other than not using the TryGetValue() method?
Thanks,
Richard
I have a teacher class which inherits from person.
And within a search class have a search method with the following:
Dictionary<String, Person> people = new Dictionary<String, Person>();
people.Add("a", new Teacher("Bob", "Smith");
Teacher teach;
if (!people.TryGetValue("Jane", out teach)
{
teach = new Teacher ("Jane", "Jones");
}
Error 1 The best overloaded method match for
'System.Collections.Generic.Dictionary<string,DataTier.VOs.VO>.TryGetValue(string,
out DataTier.VOs.VO)' has some invalid arguments C:\Documents and
Settings\Richard Box\My Documents\Visual Studio
2005\Projects\DataTier\DataTier\DataAccess\EventDAO.cs 307 26 DataTier
Error 2 Argument '2': cannot convert from 'out DataTier.VOs.EventVO' to 'out
DataTier.VOs.VO' C:\Documents and Settings\Richard Box\My Documents\Visual
Studio 2005\Projects\DataTier\DataTier\DataAccess\EventDAO.cs 307 57
DataTier
But Teacher is a Person, so why can an implicit conversion not be performed?
Is there a way around this other than not using the TryGetValue() method?
Thanks,
Richard