943,743 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 10917
  • C# RSS
Jun 7th, 2005
0

setw() function in C#?

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
silkfire is offline Offline
8 posts
since May 2005
Jun 9th, 2005
0

Re: setw() function in C#?

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EricaJanine is offline Offline
22 posts
since Jun 2005
Jun 10th, 2005
0

Re: setw() function in C#?

nah, wood like to separate the arrays, but thanx anyway =)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
silkfire is offline Offline
8 posts
since May 2005
Jun 14th, 2005
0

Re: setw() function in C#?

C# Syntax (Toggle Plain Text)
  1. int[] x = y = z = new int[10];
  2. // or I THINK this works too
  3. int[] x, y, z = new int[10];
Reputation Points: 46
Solved Threads: 2
Junior Poster
Iron_Cross is offline Offline
117 posts
since Jul 2003
Jun 18th, 2005
1

Re: setw() function in C#?

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];
Reputation Points: 13
Solved Threads: 6
Junior Poster in Training
r0ckbaer is offline Offline
55 posts
since Dec 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Download image from DB and view it...
Next Thread in C# Forum Timeline: Windows form programming tutorials?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC