r_badris
asked on
Casting string to int in c# without conversion functions
Hi All,
How to convert a string to int in C# with out using Convert.ToInt32() or Int.Parse() conversion function.
Thanks in advance,
Badri Narayanan R
How to convert a string to int in C# with out using Convert.ToInt32() or Int.Parse() conversion function.
Thanks in advance,
Badri Narayanan R
I don't think that it it possible to peform it without conversion ...
That would not stroke with the idea of OO-programming
That would not stroke with the idea of OO-programming
s thats is not possible .. sorry i didnt test it...
>> string str = "1";
>> int i = (int)str;
On this you'll get the error 'Cannot convert type string to int'
>> int i = (int)str;
On this you'll get the error 'Cannot convert type string to int'
Why don't you want to use the two built-in conversion functions (!!)
You could parse the string 'by hand' if you wanted, character by character...
But this then sounds like homework..
You could parse the string 'by hand' if you wanted, character by character...
But this then sounds like homework..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
int i = (int)str;