473,320 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Is there a way to combine formatted strings and/or arrays?

Context :

I read command line arguments using args object and print via formatted strings. Here is the sample code,

Expand|Select|Wrap|Line Numbers
  1. Console.WriteLine("I need to learn C# {0,9}", args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]); 
Is there a easy way to use the formatted strings and arrays instead of typing so much. Example i tried {0-9) to combine the formatted string but that didnt work and threw an exception - 'Input String was not in a correct format'

I manily want my code to be compact as well type less :)
Sep 24 '10 #1
1 1203
Make use of following code:

Expand|Select|Wrap|Line Numbers
  1. foreach (string argument in args)
  2. {
  3.    Console.Write(argument + " ");
  4. }
  5.  
Sep 25 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Joerg Lehmann | last post by:
I am using Python 2.2.3 (Fedora Core 1). The problem is, that strings containing umlauts do not work as I would expect. Here is my example: >>> a = 'äöü' >>> b = '123' >>> print "%-5s...
7
by: Thomas Philips | last post by:
I want to print "1 spam 4 you" using a formatted string that gets its inputs from the dictionary d={'n1':1, 's1':'spam', 'n2':4}. To do so, I write >>> x="%('n1')d %('s1')s %('n2')d you" >>> x...
5
by: Tarjei Romtveit | last post by:
I'm still a newbie into C++ programming, so I got a quite foolish string related question. Using: Dev-cpp 4.9.9.2 (I think Dev-Cpp uses a gcc compiler of some sort) If i declare a char...
5
by: swarsa | last post by:
Hi All, I realize this is not a Palm OS development forum, however, even though my question is about a Palm C program I'm writing, I believe the topics are relevant here. This is because I...
2
by: SamIAm | last post by:
I am displaying money values in a textbox like this: txtCountryPack.Text = String.Format("{0:c}", dr); I then need to updated my Database: decimal packPrice =...
8
by: frekster | last post by:
Hi. I used to be able to do this easily in vb 6 via looping and preserving the source array data/size etc. How can I do this in vb.net? I've been trying for a while now and this should be...
31
by: Tomás | last post by:
When you have compile-time strings like: "The file is of unknown format." What kind of variables do you use to store it? At the moment I'm using: char const str = "The file is of unknown...
2
by: abcjayati | last post by:
can anyone give me a program that a combines two arrays of size 10 in another array and sort them in ascending order.
3
by: Wynn Rostek | last post by:
In C# is there any way to do formatted printing like there is in C? In C, I would do sprintf(string, "%4.2f",floatvalue) to print a float value with two decimal places. I have looked around a bit,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.