Hello, I am having the hardest time getting my strings to format right
I want it to only show the first 14 chars of the string. sounds simple, but I think ive been looking at the code to long to see where im messing up :).
here's the code I have
int fCount = mwReader.FieldCount;
for ( int i = 0; i < fCount; i ++ )
{
Console.Write("{0,-15}", mwReader.GetName(i));
Console.Write(" ");
}
Console.WriteLine("".PadLeft(80, '-'));
while (mwReader.Read())
{
string description = mwReader.GetString(0);
if (description.Length > 14)
description.Substring(0, 14);
Console.WriteLine("{0,-15} {1,-15} {2,-12:C} {3,-12} {4,-12:C}",
description,
mwReader.GetString(1),
mwReader.GetValue(2),
mwReader.GetBoolean(3),
mwReader.GetValue(4)
);
}
the IF statement was my last attempt to use sub string on it but even that is not working.
Here's the out put im getting
Description ProductNo Price IsOnSale SalePrice
--------------------------------------------------------------------------------
Heaven's Come To Eearth Today 080689016271 $1.60 False
Christmas Is Jesus 080689015274 $1.60 False
Child Of Light 080689014277 $1.60 False
You Love Me Still 080689008276 $1.60 False
You Are Holy 080689007279 $1.60 False
Worship Only You 080689006272 $1.60 False
Through The Fire 080689005275 $1.60 False
So Much God 080689004278 $1.60 False
Sing To The King 080689003271 $1.60 False
Sing 080689002274 $1.85 False
Praise To The Lord Almighty. 080689001277 $1.60 False
Jude Doxology 080689000270 $1.60 True $12.95
Berceuse and Finale 00137 $60.00 False
Tell My Father 02501096 $1.80 False
I want it to look like
Description ProductNo Price IsOnSale SalePrice
--------------------------------------------------------------------------------
Heaven's Come T 080689016271 $1.60 False
Christmas Is Je 080689015274 $1.60 False
Child Of Light 080689014277 $1.60 False
You Love Me Sti 080689008276 $1.60 False
You Are Holy 080689007279 $1.60 False
Worship Only Yo 080689006272 $1.60 False
Through The Fir 080689005275 $1.60 False
So Much God 080689004278 $1.60 False
Sing To The Kin 080689003271 $1.60 False
Sing 080689002274 $1.85 False
Praise To The L 080689001277 $1.60 False
Jude Doxology 080689000270 $1.60 True $12.95
Berceuse and Fi 00137 $60.00 False
Tell My Father 02501096 $1.80 False
Please Help
and Tank you
Don