Arrays
Pages: [1]
|
|
Programming Help
|
sprinkles

2009 Sep 6 • 960
10 ₧
|
C# code private void Benter_Click(object sender, EventArgs e)
{
string mainString = INmain.Text;
string chars = "+-x/";
char [] charArray = chars.ToCharArray();
INmain.Text = charArray.ToString();
for (int i = 0; i >= 4; i++)
{
int tempInt = mainString.IndexOfAny(charArray);
INmain.Text = tempInt.ToString();
}
}
For some reason the output value is System.Char[].
I am really bad with arrays.
I changed it to this but it still no work:
C# code private void Benter_Click(object sender, EventArgs e)
{
string mainString = INmain.Text;
// string chars = "+-x/";
char [] charArray = {'+','-','x','/'};
// INmain.Text = charArray.ToString();
for (int i = 0; i >= 4; i++)
{
int tempInt = mainString.IndexOfAny(charArray);
INmain.Text = INmain.Text + tempInt.ToString();
}
}
http://www.somethingawful.com/flash/shmorky/babby.swf
using Sprinkles.Math
using Sprinkles.Common
using Sprinkles.Misc
using System.Security.Cryptography
|
|
|
|
|
(Edited 2010 Jan 18)
2010 Jan 18
|
|
|
Down Rodeo
Moth


2007 Oct 19 • 3832
57,783 ₧
|
I don't know Basic well enough to know what you're doing. Arrays are kind of easy, no? Well not easy, but yeah, they kind of are.
Lovestruck! I've fallen for a lamppost
Givin' it me utmost
Spillin' out my deepest feelings...
|
|
|
|
|
2010 Jan 19
|
|
|
|
|
|
|
2010 Jan 19
|
|
|
Down Rodeo
Moth


2007 Oct 19 • 3832
57,783 ₧
|
They are. As far as I can tell you're taking a string, turning it into an array and then back into a string, I think. You'll need to call toString on each individual element of the array. If that's what you want to do. What do you want to do?
Lovestruck! I've fallen for a lamppost
Givin' it me utmost
Spillin' out my deepest feelings...
|
|
|
|
|
2010 Jan 19
|
|
|
sprinkles

2009 Sep 6 • 960
10 ₧
|
I want to populate the charArray, with + - x / ( ), and other mathmatical operators, and then search for them within the string. Then get the indexes of each operator.
So:
(-9)+87*52
( = char (also int for the index)
- = char (also int for the index)
9 = int
) = char (also int for the index)
+ = char (also int for the index)
87 = int
* =char (also int for the index)
52 = int
http://www.somethingawful.com/flash/shmorky/babby.swf
using Sprinkles.Math
using Sprinkles.Common
using Sprinkles.Misc
using System.Security.Cryptography
|
|
|
|
|
2010 Jan 19
|
|
|
SRAW
Rocket Man

2007 Nov 6 • 1266
1 ₧
|
why dont you just split each letter into the array then check if it is one of those operators
edit: i think your that atleast, but why dont you just like check everything manaully instead of using that for loop
Thus spake SRAW
And y did u highlight this?
|
|
|
|
|
(Edited 2010 Jan 20)
2010 Jan 20
|
|
|
Down Rodeo
Moth


2007 Oct 19 • 3832
57,783 ₧
|
What's INmain?
Lovestruck! I've fallen for a lamppost
Givin' it me utmost
Spillin' out my deepest feelings...
|
|
|
|
|
2010 Jan 20
|
|
|
|
|
|
|
2010 Jan 20
|
|
|
sprinkles

2009 Sep 6 • 960
10 ₧
|
SRAW said: why dont you just split each letter into the array then check if it is one of those operators
edit: i think your that atleast, but why dont you just like check everything manaully instead of using that for loop
Because, If I understand correctly, that would give me severall different arrays; which, the whole purpose of the array is to easily use the .IndexOfAny.
http://www.somethingawful.com/flash/shmorky/babby.swf
using Sprinkles.Math
using Sprinkles.Common
using Sprinkles.Misc
using System.Security.Cryptography
|
|
|
|
|
2010 Jan 20
|
|
|
Down Rodeo
Moth


2007 Oct 19 • 3832
57,783 ₧
|
You seem to be swapping out what is in the textbox quite a lot. If I wanted to search for something in an array and get its index I'd do
code for j in sizeofarray
if array[j] == whatwewant
print array[j],j
Funnily enough not only is that pseudocode it is also Python. Just about.
Lovestruck! I've fallen for a lamppost
Givin' it me utmost
Spillin' out my deepest feelings...
|
|
|
|
|
(Edited 2010 Jan 20)
2010 Jan 20
|
|
|
|
|
|
|
2010 Jan 20
|
|
|
|
Pages: [1]
|