473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Please help with managed array syntax

I have a C# module that defines a type and then makes several arrays
of that type.

public class ArrayEntryType
{ byte member1;
.... ];
public static ArrayEntryType[] array1 = {
new ArrayEntryType(1),
new ArrayEntryType(2)};
public static ArrayEntryType[] array2 = {
new ArrayEntryType(1),
new ArrayEntryType(2)};
etc

Now, in MC++ would like to delcare a static enity that would be an
array of pointers to array1, array2 ... arrayn.

Every combination of defineing the array of pointer to an array that I
try gives me various errors about type conversions etc.

public __gc class ArrayUser {
public:
static ArrayEntryType * (array_ptr_table []) __gc[]; //
this line gives compile error

static ArrayUser (void)
{ array_ptr_table= new ArrayEntryType * [6]; //
note this line needs lots of work
array_ptr_table[0] = &array1;
array_ptr_table[1] = &array2;
}
};

The definition of array_ptr_table is the current problem, but I that
the new will also need help once the definition is correct.

Thanks for you help.

-------------------------------------------
Roy Chastain
KMSystems, Inc.
Nov 17 '05 #1
2 2373
Hi Roy!

I also don't know how to correctly solve this problem. However, there are at
least two workarounds I can think of:

1.) If array1, array2, ... are of same size, you could use a 2-dimensional
array:
ArrayEntryType* your2DimArray __gc[,] = __gc new ArrayEntryType[x, y];

2.) You could create an array of Objects, with array1, array2, ... as its
Elements.
Object* yourArray __gc[] = __gc new Object*[x];
yourArray[0] = array1;
yourArray[1] = array2;

To access the subarrays you can cast them back:
ArrayEntryType* arrayN __gc[] = (ArrayEntryType* __gc[]) yourArray[n];

Hope this helps
- Markus
"Roy Chastain" <NO*******@kmsys.com.NOSpam> schrieb im Newsbeitrag
news:ti********************************@4ax.com...
I have a C# module that defines a type and then makes several arrays
of that type.

public class ArrayEntryType
{ byte member1;
.... ];
public static ArrayEntryType[] array1 = {
new ArrayEntryType(1),
new ArrayEntryType(2)};
public static ArrayEntryType[] array2 = {
new ArrayEntryType(1),
new ArrayEntryType(2)};
etc

Now, in MC++ would like to delcare a static enity that would be an
array of pointers to array1, array2 ... arrayn.

Every combination of defineing the array of pointer to an array that I
try gives me various errors about type conversions etc.

public __gc class ArrayUser {
public:
static ArrayEntryType * (array_ptr_table []) __gc[]; //
this line gives compile error

static ArrayUser (void)
{ array_ptr_table= new ArrayEntryType * [6]; //
note this line needs lots of work
array_ptr_table[0] = &array1;
array_ptr_table[1] = &array2;
}
};

The definition of array_ptr_table is the current problem, but I that
the new will also need help once the definition is correct.

Thanks for you help.

-------------------------------------------
Roy Chastain
KMSystems, Inc.

Nov 17 '05 #2
> Now, in MC++ would like to delcare a static enity that would be an
array of pointers to array1, array2 ... arrayn.


Hello Roy,

Unfortunately array of array (aka "jagged array") is not implemented in
MC++. The latest internal build of the compiler does support this.

Also, a native array (as opposed to managed array) cannot contain managed
type due to the lack of CLR support.

--
Keiji Oenoki
Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andre | last post by:
Hi, I have a problem with calling a managed C++ function from C#. The function in C++ looks like Class::Func(char* Text) this function is compiled to an DLL and this DLL is referenced in my...
0
by: Wild Wind | last post by:
Hello, I have an event in my managed class which I declare as: __event void MyEvent(System::Byte (*fir) __gc); However, I find that when I build the class, I get very strange errors like ...
1
by: Wild Wind | last post by:
Hello, I posted this a few days back, but got no response, so I am reposting it. I have an event in my managed class which I declare as: __event void MyEvent(System::Byte (*fir) __gc); ...
5
by: Chris | last post by:
Hi, 1) I find the notation for managed arrays in C++.NET very confusing : Sometimes is it not necessary to use the pointer notation ==> short pS2 __gc = new short __gc; Sometimes it is !!!...
3
by: Wild Wind | last post by:
Hello, I made a post relating to this issue a while back, but I haven't received any answer, so here I am again. I am writing a mixed C++ dll which uses the following declaration: typedef...
2
by: The unProfessional | last post by:
Any know how to convert a managed array to an unmanaged array (ptr)? // Managed float f = new float ; // Unmanaged unsafe { float *pArray = f; // No good
36
by: Cap'n Ahab | last post by:
I have used VB3 - VB6, so learning all this OO stuff is reasonably new to me (although I looked at Java a few years ago). Anyway, I thought I would write a small class to begin with, with a...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
2
by: romcab | last post by:
Hi guys, I created a simple program which combines a managed and unmanaged c++ syntax. I have encountered a problem in compiling this program. The compiler told me to add /clr:oldSyntax but when I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.