Defaulting a template type?
SPONSORED LINKS
Hey,
Just a quick question, and im pretty sure its not possible but C# dazzles me every day with its brilliance… so imagine you have the following class:
Code:
public Circle<T>
{
private T X,Y,Radius;
public(T X, T Y, T Radius)
{ this.X = X; this.Y = Y; this.Radius = Radius; }
}
Circle<int> IntCircle = new Circle<int>(10,10,10);
Circle<double> DoubleCircle = new Circle<double>(10.0d, 10.0d, 10.0d);
Now i was wondering if there was a way to just tell it that if no template is set it should default to double, without writing a new untemplated class, like below:
Code:
// Same objects really, just first one defaulted to double
Circle DoubleCircle = new Circle(10.0d, 10.0d, 10.0d);
Circle<double> AnotherDoubleCircle = new Circle<double>(10.0d, 10.0d, 10.0d);Here is the original:
Defaulting a template type?