G
Guest
I create a lot of text files in an app I am converting to C#. In C, I could
output text to a file in the format:
int i=4;
int j=3;
int k=10;
int m=15;
fprintf(fp,"%4d %4d\n",i,j;
fprintf(fp,"%4d %4d\n",k,m;
and the output would be:
4 3
10 15
In this way, I can stuff spaces into the unneeded characters so that my
columns always lined up in a right-aligned manner.
I can't seem to duplicate this in C#, the closest I found to duplicating
this is to put,
i.ToString("0000")+" "+j.ToString("0000");
to get:
0003 0004
However, I don't want leading zeros, I want leading spaces.
Any ideas?
Thanks,
Phil
output text to a file in the format:
int i=4;
int j=3;
int k=10;
int m=15;
fprintf(fp,"%4d %4d\n",i,j;
fprintf(fp,"%4d %4d\n",k,m;
and the output would be:
4 3
10 15
In this way, I can stuff spaces into the unneeded characters so that my
columns always lined up in a right-aligned manner.
I can't seem to duplicate this in C#, the closest I found to duplicating
this is to put,
i.ToString("0000")+" "+j.ToString("0000");
to get:
0003 0004
However, I don't want leading zeros, I want leading spaces.
Any ideas?
Thanks,
Phil