Arrays

Arrays

sprinkles

Chrome Whore
2009 Sep 6 • 2547
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(); } }
 
 
 
2010 Jan 19 at 02:26 UTC — Ed. 2010 Jan 19 at 02:49 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
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.
 
 
 
2010 Jan 19 at 19:00 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Its C#, and, no, they are not easy.
 
 
 
2010 Jan 19 at 20:32 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
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?
 
 
 
2010 Jan 19 at 20:48 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
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
 
 
 
2010 Jan 19 at 20:56 UTC
SRAW
Rocket Man

2007 Nov 6 • 2525
601 ₧
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
Free Steam Games
 
 
 
2010 Jan 20 at 08:46 UTC — Ed. 2010 Jan 20 at 08:48 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
 
 
 
2010 Jan 20 at 11:26 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
INmain is my inputbox.
Benter is my button.
 
 
 
2010 Jan 20 at 16:26 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
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.
 
 
 
2010 Jan 20 at 16:32 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
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.
 
 
 
2010 Jan 20 at 16:43 UTC — Ed. 2010 Jan 20 at 16:44 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Cool, if you tell me what it means/does I might be able to emulate it in C#.
 
 
 
2010 Jan 20 at 18:14 UTC
Page [1]