473,406 Members | 2,336 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,406 software developers and data experts.

How to access C# indexer in C++

I have a C# class :

public class MyClass
{
public object this[int index]
{
}
}

In my C++ code, how to access this index method?

MyClass ^ myClass = gcnew MyClass();
myClass->????

Nov 17 '05 #1
4 1395
Lei Jiang wrote:
I have a C# class :

public class MyClass
{
public object this[int index]
{
}
}

In my C++ code, how to access this index method?

MyClass ^ myClass = gcnew MyClass();
myClass->????


How do you access it in C#?


Regards,

Ioannis Vranos
Nov 17 '05 #2
In C#, just use myClass[index].

But I have found the answer now :

myClass->get_Item(index)
"Ioannis Vranos" <iv*@guesswh.at.grad.com> ????
news:ue**************@TK2MSFTNGP12.phx.gbl...
Lei Jiang wrote:
I have a C# class :

public class MyClass
{
public object this[int index]
{
}
}

In my C++ code, how to access this index method?

MyClass ^ myClass = gcnew MyClass();
myClass->????


How do you access it in C#?


Regards,

Ioannis Vranos

Nov 17 '05 #3
Lei Jiang wrote:
In C#, just use myClass[index].

But I have found the answer now :

myClass->get_Item(index)
"Ioannis Vranos" <iv*@guesswh.at.grad.com> ????
news:ue**************@TK2MSFTNGP12.phx.gbl...
Lei Jiang wrote:

I have a C# class :

public class MyClass
{
public object this[int index]
{
}
}


This is an indexed property so you can also use the [] operator in C++
the same way you do in C#.


Regards,

Ioannis Vranos
Nov 17 '05 #4
Lei Jiang wrote:
I have a C# class :

public class MyClass
{
public object this[int index]
{
}
}

In my C++ code, how to access this index method?

MyClass ^ myClass = gcnew MyClass();
myClass->????


The name of the indexed property is Item. C# uses that name by default, but
a few classes have a different name. In the new C++ syntax, you will be able
to access C# indexers with the same syntax (i.e. directly on the class
instance). Of course, C++ will still have named indexed properties if you
find them useful.

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.
Nov 17 '05 #5

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

Similar topics

14
by: Nikhil Patel | last post by:
Hi all, Is it possible to have more than one indexer in a class. If not, are there any good alternative ways to achieve similar functionality. Thanks... -Nikhil
0
by: Brian Takita | last post by:
Hello, I am able to test an object to see if it is an indexer (IsIndexer function), however I don't know how to call the indexer without Unboxing to the object's class. Do I need to use...
1
by: Dotnetjunky | last post by:
Hi all Is it correct that there's a link between indexer and Items property in C# ? If yes, please show me what is it ? thanks in advance. -- Dotnetjunky
16
by: Yoramo | last post by:
Hello I have a class the containes several ArrayList's and I whold like to use a indexer for each one. I'm getting a compilation error. "already defines a member called 'this' with the same...
7
by: Oren | last post by:
hi I have created a class with a simple indexer what is the syntax for adding the function "Remove" ... myClass.colors=Color.Black; // WORKS O myClass.colors.Remove(); // ?? .......
7
by: Steph | last post by:
I'm learning C#. I need to implement an indexer using an array list. I have the following code and I'm getting an error "Inconsistent accessibility: indexer return type CRegs is less accessible...
6
by: pinetaj | last post by:
Hello, I have a question of using 'property' on accessing elements of array. There is an array member in a class. I'd like to restrict accessing the elements of the array through property. And...
8
by: Bill Cohagan | last post by:
I'm curious as to why C# doesn't support static indexers. Anybody know? Thanks, Bill
17
by: SemSem | last post by:
i want to know waht is an index and how we use it with a simple example including the main of the program . thanx -- Islam Khalil,
11
by: jacob navia | last post by:
Hi Suppose that I want to create an array of read only items I overload the operator. How can I detect if I am being called within a read context foo = Array; or within a write context...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...

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.