T
tshad
I am trying to move as much data from my child classes to my base classes
and am having a problem.
Original Class
***********************
using System;
using System.IO;
namespace FtsData
{
abstract class testClass
{
protected object _objInitial;
public testClass(object initial)
{
_objInitial = initial;
}
public object First
{
get { return _objInitial; }
}
}
class BoolType2 : testClass
{
public BoolType2()
{
}
public BoolType2(bool initial)
{
_objInitial = initial;
}
}
}
***********************
This works fine. but I wanted to move the Constructors from the Child to
the Base since each type I build (boolean, string, integer, etc) will have
as little code to write.
If I moved the constructor (with a value passed) to the base, it caused an
error with the void constructor:
********************************
using System;
using System.IO;
namespace FtsData
{
abstract class testClass
{
protected object _objInitial;
public testClass(object initial)
{
_objInitial = initial;
}
public object First
{
get { return _objInitial; }
}
}
class BoolType2 : testClass
{
public BoolType2()
{
}
public BoolType2(bool initial):base(initial)
{
//_objInitial = initial;
}
}
}
********************************
Now I get an error saying:
No overload for method 'testClass' takes '0' arguments
This is because I have a void constructor in my child class but not in my
base class.
But I didn't need this constructor in my initial example above. Only after
I added a constructor. It seems at that point any constructors that are in
my child class are necessary in my base class.
I found that I don't have to set it so that the child void class references
the child class (as I did with my child class with one parameter). But the
void class did have to be there.
Also, can I have my constructors in my base class but not in my child
classes?
*******************************************
using System;
using System.IO;
namespace FtsData
{
abstract class testClass
{
protected object _objInitial;
public testClass()
{
}
public testClass(object initial)
{
_objInitial = initial;
}
public object First
{
get { return _objInitial; }
}
}
class BoolType2 : testClass
{
}
}
*******************************************
Thanks,
Tom
and am having a problem.
Original Class
***********************
using System;
using System.IO;
namespace FtsData
{
abstract class testClass
{
protected object _objInitial;
public testClass(object initial)
{
_objInitial = initial;
}
public object First
{
get { return _objInitial; }
}
}
class BoolType2 : testClass
{
public BoolType2()
{
}
public BoolType2(bool initial)
{
_objInitial = initial;
}
}
}
***********************
This works fine. but I wanted to move the Constructors from the Child to
the Base since each type I build (boolean, string, integer, etc) will have
as little code to write.
If I moved the constructor (with a value passed) to the base, it caused an
error with the void constructor:
********************************
using System;
using System.IO;
namespace FtsData
{
abstract class testClass
{
protected object _objInitial;
public testClass(object initial)
{
_objInitial = initial;
}
public object First
{
get { return _objInitial; }
}
}
class BoolType2 : testClass
{
public BoolType2()
{
}
public BoolType2(bool initial):base(initial)
{
//_objInitial = initial;
}
}
}
********************************
Now I get an error saying:
No overload for method 'testClass' takes '0' arguments
This is because I have a void constructor in my child class but not in my
base class.
But I didn't need this constructor in my initial example above. Only after
I added a constructor. It seems at that point any constructors that are in
my child class are necessary in my base class.
I found that I don't have to set it so that the child void class references
the child class (as I did with my child class with one parameter). But the
void class did have to be there.
Also, can I have my constructors in my base class but not in my child
classes?
*******************************************
using System;
using System.IO;
namespace FtsData
{
abstract class testClass
{
protected object _objInitial;
public testClass()
{
}
public testClass(object initial)
{
_objInitial = initial;
}
public object First
{
get { return _objInitial; }
}
}
class BoolType2 : testClass
{
}
}
*******************************************
Thanks,
Tom