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++ / September 2007

Tip: Looking for answers? Try searching our database.

How do I create a Generic.List?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Arcadefreaque - 28 Sep 2007 19:32 GMT
I'm realizing how little I know about C++ today as I try to convert
some functionality from VB.Net to C++.

I have a procedure that I need to pass a List of objects to, and
cannot see how to do this using C++.  It's easy in VB.Net, so I'm
hoping it is just my silly misunderstanding of c++ that is preventing
me from doing this in c++.

In VB.Net, to create a couple of objects and add them into a generic
list, this is the code that is used:
' Assign parameter list for GEOCODING
Dim addrVal1 As New ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("STREET",
pAddress)
Dim addrVal2 As New ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("ZONE",
pZipcode)
Dim addrValColl As New System.Collections.Generic.List(Of
ESRI.ArcGIS.ADF.Web.Geocode.AddressValue)
addrValColl.Add(addrVal1)
addrValColl.Add(addrVal2)

In C++, I realize that creating the objects for the list would be
something like this:
Geocode::AddressValue __gc * addrVal1 = new
Geocode::AddressValue(S"STREET", pAddress);
Geocode::AddressValue __gc * addrVal1 = new
Geocode::AddressValue(S"ZONE", pZipcode);

But, how do I go about defining the AddrValColl apppropriately so that
I can add my two objects to it and then call my procedure?

Thanks in advance for any assistance you  might be able to provide.
Peter Oliphant - 28 Sep 2007 20:38 GMT
How about creating a list of void pointers? Not sure how to do it with
lists, but as an array:

#typedef   array<void^> VoidArray ;

VoidArray^ varray = gcnew VoidArray( count ) ;

for ( init 1 = 0 ; i < count ; i++ )
{
   varray[i] = 'pointer to object[i]'  ;// meta-code
}

Been a while since I worked with Lists, but there is likely a way to do this
with those instead of arrays...

[==Peter==]

> I'm realizing how little I know about C++ today as I try to convert
> some functionality from VB.Net to C++.
[quoted text clipped - 27 lines]
>
> Thanks in advance for any assistance you  might be able to provide.
Ben Voigt [C++ MVP] - 28 Sep 2007 20:58 GMT
> I'm realizing how little I know about C++ today as I try to convert
> some functionality from VB.Net to C++.
[quoted text clipped - 22 lines]
> Geocode::AddressValue __gc * addrVal1 = new
> Geocode::AddressValue(S"ZONE", pZipcode);

Since you're using generics, I'm assuming you're using .NET 2.0.  The C++
compiler was totally changed between .NET 1.x and 2.0 and the syntax you
show is no longer used.

Try

Geocode::AddressValue^ addr1 = gcnew Geocode::AddressValue ("STREET",
pAddress);
Geocode::AddressValue^ addr2 = gcnew Geocode::AddressValue ("ZONE",
pZipcode);
System::Generic::Collections::List<Geocode::AddressValue^>^ addrValColl =
gcnew System::Generic::Collections::List<Geocode::AddressValue^>();
addrValColl->Add(addrVal1);
addrValColl->Add(addrVal2);
Ben Voigt [C++ MVP] - 28 Sep 2007 21:06 GMT
>> I'm realizing how little I know about C++ today as I try to convert
>> some functionality from VB.Net to C++.
[quoted text clipped - 35 lines]
> System::Generic::Collections::List<Geocode::AddressValue^>^ addrValColl =
> gcnew System::Generic::Collections::List<Geocode::AddressValue^>();

I think I got it backwards, try System::Collections::Generic::List ...

> addrValColl->Add(addrVal1);
> addrValColl->Add(addrVal2);

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.