Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2004

Tip: Looking for answers? Try searching our database.

How to access C# indexer in C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lei Jiang - 14 Jul 2004 10:28 GMT
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->????
Ioannis Vranos - 14 Jul 2004 14:22 GMT
> I have a C# class :
>
[quoted text clipped - 9 lines]
> MyClass ^ myClass = gcnew MyClass();
> myClass->????

How do you access it in C#?

Regards,

Ioannis Vranos
Lei Jiang - 14 Jul 2004 15:39 GMT
In C#, just use myClass[index].

But I have found the answer now :

myClass->get_Item(index)

> > I have a C# class :
> >
[quoted text clipped - 15 lines]
>
> Ioannis Vranos
Ioannis Vranos - 14 Jul 2004 17:26 GMT
> In C#, just use myClass[index].
>
[quoted text clipped - 10 lines]
>>>    }
>>>}

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

Regards,

Ioannis Vranos
Brandon Bray [MSFT] - 14 Jul 2004 19:34 GMT
> I have a C# class :
>
[quoted text clipped - 9 lines]
> 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.

Signature

Brandon Bray, Visual C++ Compiler         http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.