473,811 Members | 3,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_tabl e []) __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 2382
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*******@kmsy s.com.NOSpam> schrieb im Newsbeitrag
news:ti******** *************** *********@4ax.c om...
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_tabl e []) __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
1759
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 C# project and I can see that I could call this function like Func(sbyte* ).
0
856
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 error C2143: syntax error : missing ')' before ';'
1
1255
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); However, I find that when I build the class, I get very
5
1085
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 !!! (aparently when declaring an array of managed types) ==> String* pString = new String*; Why this difference in notations ?
3
1779
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 System::Byte ByteArray __gc;
2
1612
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
2123
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 property and 2 methods, along with a constructor (where you use New(), I think, yes?). So, I decided to create a class that represents a die, which can be rolled - using a Roll() method - and which has a property to find out the value on the face of...
2
6971
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 attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
2
1460
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 added it, the compiler cannot interpret the managed syntax. Hope you can help me. #include "stdafx.h" using namespace System; __nogc class Container { int m_value;
0
9605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.