Often with a class you want the application to use structures or variables that can be passed to the classes functions to be read or written with data. There is no real difference between a class or structure in c++.NET so create the structure as a class.

In the header file of a class create this before the the main class’s ref class MyClassName (must be before so you can reference the class names in the main class)

	//------------------------------------------
	//----- CLASSES FOR CONFIGURATION DATA -----
	//------------------------------------------
	public ref class MyStructureClassName
	{
	public:
		property int Connection;		//Define the variables types here
		property String ^Name;
		property array ^Type;
		property array ^IpAddress;

		MyStructureClassName::MyStructureClassName(void)
		{
			//Strings and arrays will be nullptr until created
			Name = "";
			Type = gcnew array(NUM_OF_CONTROLLERS);	//Create them in a constructor
			IpAddress = gcnew array(NUM_OF_CONTROLLERS);
		}

	};

	//Now your main class...
	//-------------------------------
	//----- CONFIGURATION CLASS -----
	//-------------------------------
	ref class Configuration
	{
	The main class
In your main application

//IN YOUR DECLARATIONS:
//	private: MyClassNamespace::MyStructureClassName ^MyStructure1;
//IN YOUR CONSTRUCTOR
//	MyStructure1= gcnew MyClassNamespace::MyStructureClassName();
//START USING
//	MyStructure1-># = #;

Serializing A Class

See in serialization section here

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.