Cannot convert from ref Class to ref Object
Posted on 2006-06-29
I have convert a VB application to C#. I am trying to debug it. I have got one error where I am calling a function proving it an instance of a class to an object as a ref.
ClassCompany clsCompany = new ClassCompany();
intCount = ModUtils.gfncintProcessTemplateLoop(ref clsCompany)
public static int gfncintProcessTemplateLoop(ref object clsRecordset)
I get the following error.
cannot convert from 'ref SiteGen.ClassCompany' to 'ref object'
gfncintProcessTemplateLoop is a generic function and is used to pass different classes and is the reason why the class is delcares as an object.
I also tried casting clsCompany into an Object.
intCount = ModUtils.gfncintProcessTemplateLoop(ref (object)clsCompany)
Then I got another error saying
A ref or out argument must be an lvalue
Can anybody help me with this one please.