How to define this....

  • Thread starter Thread starter Alex Sanchez.
  • Start date Start date
A

Alex Sanchez.

Hi,

If I have this :

public struct SGPoint
{
public double X;
public double Y;
}

public struct SGRect
{
public SGPoint Emin;
public SGPoint Emax;
}


How do I define a constant ? Example:

public class SGGlobals
{
public const SGRect Extension = ????;
}



Also, I have this:

public struct PJUnits
{
public string id;
public double to_meter;
public string name;
}

then, how to define a constant array of x elements in:

public class SGGlobals
{
public const PJUnits [] punits = ???;
}


Thanks
Alex
 
// Here's one option, using readonly, rather than const:

public struct SGRect
{
public SGPoint Emin;
public SGPoint Emax;
public SGRect( double Xmin, double Xmax, double Ymin, double Ymax )
{
Emin.X = Xmin;
Emin.Y = Ymin;
Emax.X = Xmax;
Emax.Y = Ymax;
}
}

public class SGGlobals
{
public readonly SGRect Extension = new SGRect( 0, 0, 100, 100 );
}
 
Back
Top