Instead of using
(char) 48 you could also use
'0' which is a char. Makes it a little easier to read. Just my $0.02.
Einar
>Gerard,
>
>"0" is a string, the PadLeft() method wants a char. You need to know the ASCII code for zero, which is 48.
>
>MyNum1 = dr["num_nexta"].ToString().PadLeft(5,(char)48);
>
>
>~~Bonnie
>
>
>
>>Hi Bonnie... wonder if you know whats wrong with this line:
>>string MyNum1
>>MyNum1 = dr["num_nexta"].ToString().PadLeft(5,"0" );
>>
>>Its coming up with 2 error messages :
>> ...has some invalid arguments
>> ...argument '2' cannot accept string to char
>>
>>Regards,
>>Gerard
>>
>>
>>
>>
>>>Gerard,
>>>
>>>.NET string types have Substring methods. Integer types have .ToString() methods.
>>>
>>>~~Bonnie
>>>
>>>
>>>
>>>>Another question on manipulating strings.
>>>>I have a numeric field (N 10) and I want to take the last 5 characters
>>>> and include it in a field with other text.
>>>>
>>>>e.g.
>>>>MyNewNum = "ABC" + Substr(str(MyNum),6,5) + 'XYZ'
>>>>to end up as : ABC00035XYZ (The 00035 is left zeroed MyNum)
>>>>
>>>>How would this be done in c sharp.
>>>>
>>>>Thanks in advance for any help.
>>>>
>>>>Gerard
Semper ubi sub ubi.