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?

Recommended Answers

All 4 Replies

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?

nah, wood like to separate the arrays, but thanx anyway =)

int[] x = y = z = new int[10];
// or I THINK this works too
int[] x, y, z = new int[10];

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];

commented: Good info +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.