|
-
March 7th, 2005, 01:07 PM
#1
C# Writeln
I had a question with the writeln statement. I am kind of new to C#
I was wondering if you could do something like this w/ the writeln statement
To displat 2 integers you must do something like
int i1,i2
Console.Writeln(i1 + "==" + i2)
However, is there a way to do something similiar to C
int i1, i2
Console.Writeln("%i==%i",i1,i2)
Thanks
-
March 7th, 2005, 03:47 PM
#2
Re: C# Writeln
take a look at this:
Console.WriteLine("Tip total/rate:" + ControlChars.Tab + "{0,8:c} ({1 1})", tip, tipRate)
let me know if this helps you
-
March 7th, 2005, 03:48 PM
#3
Re: C# Writeln
Yup,
----
Console.WriteLine("{0} == {1}", i1, i2);
----
just use { } around the number, or w/e in the order they appear after the comma.
Last edited by MAL1C3; March 7th, 2005 at 03:53 PM.
-
March 8th, 2005, 03:54 AM
#4
Re: C# Writeln
 Originally Posted by MAL1C3
Console.WriteLine("{0} == {1}", i1, i2);
just use { } around the number, or w/e in the order they appear after the comma.
Well, you can specify any order you want:
Code:
int i1=1;
int i2=2;
int i3=3;
Console.WriteLine("{0} - {2} - {1}", i1, i2, i3);
Output:
-
March 8th, 2005, 04:14 AM
#5
Re: C# Writeln
That is legal too:
Code:
int i1=1;
Console.WriteLine("{0} - {0}", i1);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|