Solved

easy building a string c#

Posted on 2008-06-26
7
249 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
Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

 
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 500 total points
ID: 21878523
sorry copied to much of the date
0

Featured Post

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

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…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

695 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