Off the top of my head:
Regards,
Jeff
============= UNTESTED CODE ============
using System;
namespace TestStruct1
{
// immutable structure
struct ExampleStruct
{
public readonly double fParam1;
public readonly double fParam2;
public readonly double fParam3;
public readonly double fParam4;
public ExampleStruct(double fParam1, double fParam2, double fParam3,
double fParam4)
{
this.fParam1= fParam1;
this.fParam2= fParam2;
this.fParam3= fParam3;
this.fParam4= fParam4;
}
}
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
private ExampleStruct es;
public Class1(ExampleStruct es)
{
this.es= es;
}
public void Print()
{
System.Console.WriteLine(es.fParam1);
System.Console.WriteLine(es.fParam2);
System.Console.WriteLine(es.fParam3);
System.Console.WriteLine(es.fParam4);
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
ExampleStruct es= new ExampleStruct(
0.1234,
1.2345,
2.3456,
3.4567);
// es.fParam1= 2; // build error as expected
Class1 c1= new Class1(es);
c1.Print();
System.Console.ReadLine();
}
}
}
/*typedef struct
{
double fParam1;
double fParam2;
double fParam3;
double fParam4;
} EXAMPLE_STRUCT;
const <classname>::sm_sData =
{
0.1234,
1.2345,
2.3456,
3.4567,
};
*/
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!