setw() function in C#?

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2005
Posts: 8
Reputation: silkfire is an unknown quantity at this point 
Solved Threads: 0
silkfire's Avatar
silkfire silkfire is offline Offline
Newbie Poster

setw() function in C#?

 
0
  #1
Jun 7th, 2005
Hi, I'd like to have tabs in my console app, but instead of using \t, I'd like to use an equivalent of the C++ setw() method in C#. Any ideas of what I might use?

And another thing, in C++, you would declare more than one array with indexes like this:

int x[10], y[10], z[10];

Is there a shorter way than writing like this in C# :

int[] x = new int[10];
int[] y = new int[10];
int[] z = new int[10];

Thanx for the help, if someone knows.

Edit: Oh, damnit, wrong forum! Can a mod move it to the C# forum?
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 22
Reputation: EricaJanine is an unknown quantity at this point 
Solved Threads: 0
EricaJanine's Avatar
EricaJanine EricaJanine is offline Offline
Newbie Poster

Re: setw() function in C#?

 
0
  #2
Jun 9th, 2005
Hey there silkfire,

On the array question, do you need three distinct arrays? You could create a multidimensional array, like a jagged array:

int [][][] njaggedArray = new int [10][10][10];

Will that work?
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 8
Reputation: silkfire is an unknown quantity at this point 
Solved Threads: 0
silkfire's Avatar
silkfire silkfire is offline Offline
Newbie Poster

Re: setw() function in C#?

 
0
  #3
Jun 10th, 2005
nah, wood like to separate the arrays, but thanx anyway =)
Reply With Quote Quick reply to this message  
Join Date: Jul 2003
Posts: 117
Reputation: Iron_Cross is an unknown quantity at this point 
Solved Threads: 2
Iron_Cross's Avatar
Iron_Cross Iron_Cross is offline Offline
Junior Poster

Re: setw() function in C#?

 
0
  #4
Jun 14th, 2005
  1. int[] x = y = z = new int[10];
  2. // or I THINK this works too
  3. int[] x, y, z = new int[10];
elitehackers.info
Today's Penny-Arcade!
Pain is weakness leaving the body!
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 55
Reputation: r0ckbaer is an unknown quantity at this point 
Solved Threads: 6
r0ckbaer r0ckbaer is offline Offline
Junior Poster in Training

Re: setw() function in C#?

 
1
  #5
Jun 18th, 2005
setw() equiv would be sth like this:

String.Format("{0,10:D}", 2) : will format number 2 as a string of width 10 aligned to the right, use -10 to have it aligned on the left

as for declaring the vars, you can do it like this:

int[] a, b, c = new int[10];
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC