|
You can better use the StringBuilder for these kind of operations, they are faster:
StringBuilder result = new StringBuilder();
foreach(object item in ArrayList)
{
result.AppendLine(item.ToString());
}
String result2 = result.ToString();
Now you have them seperated by a linebreak.
You can also just use the append like this to separate by spaces:
StringBuilder result = new StringBuilder();
foreach(object item in ArrayList)
{
result.Append(item.ToString() + " ");
}
String result2 = result.ToString();
result2 = result2.Remove(result2.Length-1);
|
|
|
|
|
Deresen wrote: result.Append(item.ToString() + " ");
when result is a StringBuilder you should not use string concatenation at all!
Instead do:
result.Append(item.ToString());
result.Append(" ");
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:43 PM
|
|
|
|
|
thanks a lot
its working fine
the quieter u become more u hear
|
|
|
|
|
Try this,
ArrayList temp = new ArrayList();
temp.Add("A");
temp.Add("B");
string delim = " ";
string result = string.Join(delim, (string[])temp.ToArray(typeof(string)));
|
|
|
|
|
Hello,
I started on the batchs programs , and I must do the following triat in batch mode:
1: Read a CSV file, all addresses line by line.
2: Open a Word file by writing the lines of the CSV.
How i can this treatment be done in batch mode? thank you very much
|
|
|
|
|
What do you mean by "batch mode"? Is it that you need to do this for many files, or do you mean that it's a console application?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i mean the automatique mode of traitments, when we excute the batch file he do the traitment on CSV file, thank you.
|
|
|
|
|
Sorry, that still doesn't seem to make any sense
|
|
|
|
|
I don't think anyone has understood what is it that you want.
Do you want to write a programme in c# or do you just want to know how to start Microsoft Word via a batch file which you can run from the windows command prompt?
If it is a batch file you want then create a text file with notepad and name it e.g. batch.cmd
In the file write one line
start winword "datafile.csv"
Substitute datafile.csv with the path to your csv file.
Alan.
|
|
|
|
|
Or look into writing a macro in Word.
|
|
|
|
|
Hello
Forgive me if this is the wrong section ...
maybe someone know a web service that give the weather in the world ?
i need it for shcool project...
thanx
|
|
|
|
|
|
|
hi
how to create GUI for back end so that we can create and alter the database
for MS SQL using C# in Windows application.
|
|
|
|
|
create a form -> put on some controls -> make the controls do sql stuff
now you have an idea you can give it a try, then come back if you get any specific problems (other than 'i cant be bothered to try myself so someone give me the code' syndrome)
If only MySelf.Visible was more than just a getter...
|
|
|
|
|
How about simply using Management Studio? If you don't know how to create an application I suspect you are going to be struggling with the SQL even more
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
|
I wrote the following query in sql server 2005 but it didn't work.
SELECT Branch_no, no_of_employees, in_date, The_in_time, the_out_time FROM (
SELECT Branch_no, count(emp_no) as no_of_employees, in_date,
Cast(DATEPART(HOUR,in_time) as varchar(2)) + ':' +
Cast(DATEPART(MINUTE,in_time) as varchar(2)) The_in_time,
Cast(DATEPART(HOUR,out_time) as varchar(2)) + ':' +
Cast(DATEPART(MINUTE,out_time) as varchar(2)) The_out_time,
FROM Attendance
group by Branch_no, in_date )
WHERE The_in_time >= '6.00' ;
Actualy what I want is to get no of employees in each branch who has come to the office after 6.00 AM. I had to cast datetime fields to extract the time portion because it holds both date and time parts.
ex: 01/01/2009 06:00:00 AM
pls help me regarding above matter.
thanks in advance.
|
|
|
|
|
Try this,
SELECT Branch_no, COUNT(*) EmployeeCount
FROM Attendance
GROUP BY Branch_no
HAVING DATEPART(HH,in_time) >= 6
ORDER BY COUNT(*) DESC
If it doesnt work, try posting the message in the database forums
|
|
|
|
|
I had two hundered tables in database. I want to retrive the tables with one common field.How to does this .I Want use C# and Sql .I had different Tonnage in all the tables. if i want to call 300 tonnage in that all the tables(200 tables).How to retrive it from the datatable in the database.
thank's in adv
lavan
|
|
|
|
|
if you are using oracle the following query can be used to retrieve the table names based on the column-name
select * from dba_tab_columns where lower(owner) = 'order_schema' and lower(column_name) like '%column-name%'
Satish
|
|
|
|
|
Hi All,
Can you please help me in solving the below problem.
I am trying to access the Windows schduler task programmatically using c# to enable/disable the task.
The task is already created. Can you give me some idea how do i go about it?
Thanks in advance.
Regards,
Sunny
|
|
|
|
|
The last time I did this was by COM interop to the ITaskScheduler interface.
«_Superman_»
|
|
|
|
|
|
Need to update application configuration
private void UpdateAppSettings( string settingName, string settingValue)
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
AppSettingsSection appSettings = config.AppSettings;
KeyValueConfigurationElement setting = appSettings.Settings[settingName];
setting.Value = settingValue;
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
Not able to build the application error showing thet Configuration is not there in System.Configuration namespace
|
|
|
|