Context :
I read command line arguments using args object and print via formatted strings. Here is the sample code, - 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 :)
1 1221
Make use of following code: -
foreach (string argument in args)
-
{
-
Console.Write(argument + " ");
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 %-5s\n%-5s %-5s" % (a,a,b,b)
äöü äöü
123 123
I would expect, that the displayed width of a or b is the same: 5 characters.
|
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 % d
Traceback (most recent call last):
File "<pyshell#22>", line 1, in -toplevel-
x % d
|
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 string like this:
char szString = "Hello";
|
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 believe the problem centers
around my handling of strings, arrays, pointers and dynamic memory
allocation. Here is the problem I'm trying to solve:
I want to fill a list box with a list of Project Names from a database
(in Palm this is more...
|
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 = Convert.ToDecimal(txtCountryPack.Text.Trim());
The problem is that the value is in a formatted format i.e. $300.00
How do I remove the formatting with have to do a SubString?
Cheers.
| |
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 an easy task but it just isn't clicking.
For some reason, the preserve doesn't seem to be working.
|
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 format.";
Do some of you use:
|
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.
|
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, but have not run across anything
like this in C#, maybe I am just missing something.
Many thanks,
Wynn
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |