Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

convert arrayList to string

Posted on 2006-11-09
6
Medium Priority
?
254 Views
Last Modified: 2010-04-16
I need to convert an arrayList to a string so I can pass the parameter into my method that requires a string parameter:

ArrayList repEmailList = RepresentationDAO.GetEmailList(anAddress.StateAbr);
//foreach (string emailAddress in repEmailList)

SendMail.Send(repEmailList, "info@compasslearning.com", "CompassLearning Sales Information Request", strmsg);

repEmailList needs to be converted to a string

Thanks for any help.
0
Comment
Question by:-Dman100-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:Expert1701
ID: 17907953
Do you want to send one email to all the recipients?

  string addresses = "";
  foreach(string emailAddress in repEmailList)
    addresses += (emailAddress=="" ? "" : ";") + emailAddress;

  SendMail.Send(addresses, ...
0
 

Author Comment

by:-Dman100-
ID: 17908041
yes, I'm only sending one email to all recpients.
0
 
LVL 11

Expert Comment

by:Expert1701
ID: 17908063
And I made a mistake in my code, it should have been:

  string addresses = "";
  foreach(string emailAddress in repEmailList)
    addresses += (addresses=="" ? "" : ";") + emailAddress;

  SendMail.Send(addresses...

But that should do it!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:-Dman100-
ID: 17908066
If I may ask, what is this line doing:  addresses += (emailAddress=="" ? "" : ";") + emailAddress;
0
 
LVL 11

Accepted Solution

by:
Expert1701 earned 2000 total points
ID: 17908201
the correct one is,

  addresses += (addresses=="" ? "" : ";") + emailAddress;

It checks to see if this is the first email address and if not, includes a semicolon before adding it.  It is so you do not have an extra ';' either at the start or the end of your string.
0
 

Author Comment

by:-Dman100-
ID: 17908498
Thanks for your help!  It works great!

Regards,
-D-
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question