I have an array that I want to be able to access in two separate methods and also in other files. To do this I have had to declare it as Static, can this be done another way? because I don't want to declare it as static

This is an example of part of my code.

ref struct StrCls
{
    static cli::array<String ^, 2> ^ CombinedArr = gcnew cli::array<String ^, 2>(100,20);

        void write_array()
        {
            StreamWriter^ MyStream = gcnew StreamWriter("c:\\log.txt");
        
            for (int n=0;n<100;n++)
                for (int m=0;m<20;m++)
                    MyStream->Write(CombinedArr[n,m]);

		        MyStream->Flush();
        }

	
        void merge_array(cli::array<String ^, 2> ^% PassedArr)
        {

            for(int n=0;n<10; n++)
	        for(int m=0;m<2; m++)
                    CombinedArr[n,m] = PassedArr[n,m];

	}
};

Recommended Answers

From my knowledge u can access an array through a pointer or a vector I think

Jump to Post

All 2 Replies

From my knowledge u can access an array through a pointer or a vector I think

Solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.