?
Solved

easy building a string c#

Posted on 2008-06-26
7
Medium Priority
?
253 Views
Last Modified: 2013-12-16
string FileName = "";
                string Pools = "";
                if (chkboxWheat.Checked)
                    Pools = "Wheat ";
                if (chkboxDurum.Checked)
                    Pools += "Durum ";
                if (chkboxBarley.Checked)
                    Pools += "Barley ";
                if (chkboxDesBarley.Checked)
                    Pools += "Des Barley ";
                FileName = dr["PRICE_LIST_HDR_ID"] + " " + dr["LOAD_TYPE_NAME"] + Pools + " " + System.DateTime.Now + " " + ".xls";

I am not sure if there is a better way to concate the Pools.
Also for System.DateTime I need July 2 for example.
0
Comment
Question by:mathieu_cupryk
[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
  • 4
  • 2
7 Comments
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21878328
i would use a StringBuilder under the System.Text namespace
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 21878369
And to get the date format you want:
System.DateTime.Now.ToString("MMMM d");
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21878405
       System.Text.StringBuilder sb = new System.Text.StringBuilder();
        string FileName = "";
        if (chkboxWheat.Checked)
            sb.Append("Wheat ");
        if (chkboxDurum.Checked)
            sb.Append("Durum ");
        if (chkboxBarley.Checked)
            sb.Append("Barley ");
        if (chkboxDesBarley.Checked)
            sb.Append("Des Barley ");
        FileName = string.Concat(dr["PRICE_LIST_HDR_ID"], " ", dr["LOAD_TYPE_NAME"],
                    sb.ToString(), " ", System.DateTime.Now.ToString("MMMM d");" ", ".xls");
0
Technology Partners: 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!

 
LVL 16

Expert Comment

by:burakiewicz
ID: 21878414
date compliments of j
0
 

Author Comment

by:mathieu_cupryk
ID: 21878489
              FileName = string.Concat(dr["PRICE_LIST_HDR_ID"], " ", dr["LOAD_TYPE_NAME"], sb.ToString(), " ", System.DateTime.Now.ToString("MMMM d");" ", ".xls");

there is an error in this string.
0
 

Author Comment

by:mathieu_cupryk
ID: 21878497
 FileName = string.Concat(dr["PRICE_LIST_HDR_ID"].ToString(), " ", dr["LOAD_TYPE_NAME"].ToString(), sb.ToString(), " ", System.DateTime.Now.ToString("MMMM d"), " ", ".xls");      
             
0
 
LVL 16

Accepted Solution

by:
burakiewicz earned 2000 total points
ID: 21878523
sorry copied to much of the date
0

Featured Post

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.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 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