Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
Pages: 1
Other than the classic Convert.ToInt32(string), I thought of another way to convert a string into an int.
This is what I came up with:
string demo = "45";
public int StringToInt(string demo)
{
int val = 0;
for (int i = 0; i <= 1000000; i++)
{
if (demo == i.ToString())
{
val = i;
break;
}
}
return val;
}
Disadvantages:
Your pc may lag while this takes place if it is slow
It can only take values up to the specified index (here, 1 million)
Instead of a nooby method of adding each number and string-ized version of it into an array or dictionary, this can be used.
This is not as efficient as the one provided by Microsoft, but this is just an idea. Not telling anyone to use it.
Offline
If you're telling yourself it's only worse than the method already implemented, why would you make it or even post it?
Just makes me curious.
Offline
string demo = "45";
public int StringToInt(string demo)
{
int val = 0;
for (int i = 0; i <= 1000000; i++)
{
for (int j = 0; j <= demo.Length; j++)// where is this used?
{
if (demo == i.ToString())
{
val = i;
break;
}
}
}
return val;
}
string demo = "45";
public int StringToInt(string demo)
{
int val = 0;
for (int i = 0; i <= 1000000; i++)
{
if (demo == i.ToString())
{
val = i;
break;
}
}
return val;
}
still useless
if you can read this....good for you
Offline
you asked for it
if you can read this....good for you
Offline
Other than the classic Convert.ToInt32(string), I thought of another way to convert a string into an int.
This is what I came up with:
aweful code
Disadvantages:
a LOT of disadvantages.
Instead of a nooby method of adding each number and string-ized version of it into an array or dictionary, this can be used.
This is not as efficient as the one provided by Microsoft, but this is just an idea. Not telling anyone to use it.
Could you please think a little bit before you post something. I usually don't get involved with people asking question that can be answered using this wonderful tool called GOOGLE (I thought that people could tell the difference between the EEforums and Google (or even stackoverflow), but I was wrong)
But THIS? It's a whole new level...
So again: Think a bit before posting... Ask yourself if it's really useful. If not, keep it for yourself.
Offline
Let's not post ridiculous code on this forum.
string numberString = "45";
int number;
if (int.TryParse(numberString, out number))
{
//Continue if parsed successfully;
}
If there was even the slightest chance that this thread wasn't started as a troll, there's no hope for you.
Other than the classic Convert.ToInt32(string)
It gets easier: int.Parse(variable);
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
Guys, all of you are wrong!
Where humanity will be if all the code will be correctly and efficiently written?
Testers will no longer have a job...
All apps will run faster so CPU fabricants will no longer sell anything because nobody will need stronger processing power.
So I must say "Thanks that you exist Alkazam1448, and you bring more money to our pockets."
Everybody edits, but some edit more than others
Offline
Guys, all of you are wrong!
Where humanity will be if all the code will be correctly and efficiently written?
Testers will no longer have a job...
All apps will run faster so CPU fabricants will no longer sell anything because nobody will need stronger processing power.
So I must say "Thanks that you exist Alkazam1448, and you bring more money to our pockets."
if you can read this....good for you
Offline
Guys, all of you are wrong!
Where humanity will be if all the code will be correctly and efficiently written?
Testers will no longer have a job...
All apps will run faster so CPU fabricants will no longer sell anything because nobody will need stronger processing power.
So I must say "Thanks that you exist Alkazam1448, and you bring more money to our pockets."
On topic: It has many disadventages and no adventages, don't use it
/thread
Offline
Zumza wrote:Guys, all of you are wrong!
Where humanity will be if all the code will be correctly and efficiently written?
Testers will no longer have a job...
All apps will run faster so CPU fabricants will no longer sell anything because nobody will need stronger processing power.
So I must say "Thanks that you exist Alkazam1448, and you bring more money to our pockets."▼Hidden text
Offline
public static int? ToInt(string value)
{
for (int i = 0; i < int.MaxValue; i++)
{
if (value == i.ToString())
{
return i;
}
}
return null;
}
It's beautifully inefficient, it's an art. It must be respected!
Offline
Pages: 1
[ Started around 1732476928.9426 - Generated in 0.076 seconds, 12 queries executed - Memory usage: 1.65 MiB (Peak: 1.87 MiB) ]