K
Karthik D V
Is there any way to call the base class constructor conditionally.
For Example
class Shape
{
public Shape(int x)
{
}
}
class Rectangle : Shape
{
Shape(int x, int y) : base(x)
{
}
}
This works fine...
But what if i need something like this ??
class Rectangle : Shape
{
Shape(int x, int y)
{
if( x > y) //Some condition
{
// How Do I pass x value to base class here.?
}
}
}
As for as i know this is not possible. Am I right here????
For Example
class Shape
{
public Shape(int x)
{
}
}
class Rectangle : Shape
{
Shape(int x, int y) : base(x)
{
}
}
This works fine...
But what if i need something like this ??
class Rectangle : Shape
{
Shape(int x, int y)
{
if( x > y) //Some condition
{
// How Do I pass x value to base class here.?
}
}
}
As for as i know this is not possible. Am I right here????