C
Claire
I've explained the problem in the following code snippet. I want to share
single functions for use by several data types.
In this function I call different functions to fill out the original object
"o" that is passed in.
FileGroup is a derivative of an ArrayList object.
Can I fix this problem or will I have to create a mass of overloaded
functions for the whole path from where o originates right through to the
database?
public static bool ReadTourTemplate(ref object o)
{
if (o is Tour)
{
Foo;
}
else if (o is Logic.Collectors.DI225D.Files.FileGroup)
{
// compiler complains if I attempt to do the following
// return readFileGroup(ref ( Logic.Collectors.DI225D.Files.FileGroup)o)
// so I cast o to "create" t and pass that.
Logic.Collectors.DI225D.Files.FileGroup t =
(Logic.Collectors.DI225D.Files.FileGroup)o;
return readFileGroup(ref t );
// at this stage t is a FileGroup containing a list of files and is what
I expect
// On the other hand, object o is no longer the "same" object as t and
the list of files is empty.
}
return false;
}
private static bool readFileGroup(Logic.Collectors.DI225D.Files.FileGroup
Group)
{
foobar;
}
single functions for use by several data types.
In this function I call different functions to fill out the original object
"o" that is passed in.
FileGroup is a derivative of an ArrayList object.
Can I fix this problem or will I have to create a mass of overloaded
functions for the whole path from where o originates right through to the
database?
public static bool ReadTourTemplate(ref object o)
{
if (o is Tour)
{
Foo;
}
else if (o is Logic.Collectors.DI225D.Files.FileGroup)
{
// compiler complains if I attempt to do the following
// return readFileGroup(ref ( Logic.Collectors.DI225D.Files.FileGroup)o)
// so I cast o to "create" t and pass that.
Logic.Collectors.DI225D.Files.FileGroup t =
(Logic.Collectors.DI225D.Files.FileGroup)o;
return readFileGroup(ref t );
// at this stage t is a FileGroup containing a list of files and is what
I expect
// On the other hand, object o is no longer the "same" object as t and
the list of files is empty.
}
return false;
}
private static bool readFileGroup(Logic.Collectors.DI225D.Files.FileGroup
Group)
{
foobar;
}