How is this possible? Anyone has any idea? the type "string" is different than the char* string in C++.
For example, if I have the string "12", and I want it as an int 12
best regards
Henrik
Printable View
How is this possible? Anyone has any idea? the type "string" is different than the char* string in C++.
For example, if I have the string "12", and I want it as an int 12
best regards
Henrik
Because .NET enforces strong typing, converting a string to an int is not a valid conversion operation. I'm not exactly sure there is no way around this, so you many want to play with the System.Convert class. If I was at my computer, I would try for myself..;)
The thing I am trying to do is to read a line of text from a file...
there I use string.substring() to fetch the parameter I need.
Then I need to upload the info to an SQL db into an int field.
The variable is really a week number, so I really don't want to change the db field. It feels very wrong. I won't do any arithmetics, just basic comparisons with boolean operators.
Anyone with suggestion, please shout!!!!
btw
using System.Convert;
won't work... unknown class...
best regards
Henrik
here go
Code:System.Convert.ToInt16(MyString)
Then you prolly have other problems post your codeQuote:
Originally posted by MrNorth
btw
using System.Convert;
won't work... unknown class...
best regards
Henrik
The code is a bit large to post on the forum... but I declare my namespaces like standard procedure:
using System.IO;
using System.String;
etc
etc
It seems like intellisense won't recognize the Convert class as member of System??? Anything I have to add???
Anything I can try?
thansk for the answer btw... :)
best regards
Henrik
You need this:
Code:using System;
//.... Rest of your code
Solved it
I could just write Convert.whatevermethod();
no namespace declaration was needed.... spoooky :)
best regards
Henrik