RSS Forums RSS
Please support our C# advertiser: Programming Forums
Views: 7538 | Replies: 4
Reply
Join Date: May 2005
Posts: 8
Reputation: silkfire is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
silkfire's Avatar
silkfire silkfire is offline Offline
Newbie Poster

setw() function in C#?

  #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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: The Woodlands, TX during the week, Bryan/College Station on the weekends.
Posts: 21
Reputation: EricaJanine is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
EricaJanine's Avatar
EricaJanine EricaJanine is offline Offline
Newbie Poster

Re: setw() function in C#?

  #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  
Join Date: May 2005
Posts: 8
Reputation: silkfire is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
silkfire's Avatar
silkfire silkfire is offline Offline
Newbie Poster

Re: setw() function in C#?

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

Re: setw() function in C#?

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

Re: setw() function in C#?

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 11:33 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC