By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,471 Members | 722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,471 IT Pros & Developers. It's quick & easy.

Writing using same format in a loop

P: 13
I want to write a number (will vary) of data using the same format on a single line like:

i know i can do this like:
LogWriter.WriteLine();
for (i=0; i<Number; i++)
{
LogWriter.Write("{0,3} ", Data[i]);
}

but that seems a bit clumsy to me

I would like to have this in ONE statement (or less 'long')
is this posisble?
Feb 13 '09 #1
Share this Question
Share on Google+
1 Reply


100+
P: 179
You could wrap it in a new method....

Expand|Select|Wrap|Line Numbers
  1. private void WriteData(char[] Data, int Number)
  2. {
  3.    for (i=0; i<Number; i++)
  4.    {
  5.       LogWriter.Write("{0,3} ", Data[i]);
  6.    }
  7. }
  8.  
Then just call WriteData(data, 3) for example.
Feb 13 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.