Forum   Search   Register   Log in SUPERJER FORUM
 

Arrays

Pages: [1]
Programming Help
sprinkles

Chrome Whore
2009 Sep 6 • 2430
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(); } }
...then I got some ap, and shot a big ass lazar at everyone.
    (Edited 2010 Jan 18 at 18:49)     2010 Jan 18 at 18:26
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5258
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.
Everyone stares when you walk in the room, they stare when you go....
    2010 Jan 19 at 11:00
sprinkles

Chrome Whore
2009 Sep 6 • 2430
10 ₧
Its C#, and, no, they are not easy.
...then I got some ap, and shot a big ass lazar at everyone.
    2010 Jan 19 at 12:32
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5258
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?
Everyone stares when you walk in the room, they stare when you go....
    2010 Jan 19 at 12:48
sprinkles

Chrome Whore
2009 Sep 6 • 2430
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
...then I got some ap, and shot a big ass lazar at everyone.
    2010 Jan 19 at 12:56
SRAW
Rocket Man

2007 Nov 6 • 2068
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
    (Edited 2010 Jan 20 at 00:48)     2010 Jan 20 at 00:46
Down Rodeo
Cap'n Moth of the Firehouse

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

Chrome Whore
2009 Sep 6 • 2430
10 ₧
INmain is my inputbox.
Benter is my button.
...then I got some ap, and shot a big ass lazar at everyone.
    2010 Jan 20 at 08:26
sprinkles

Chrome Whore
2009 Sep 6 • 2430
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.
...then I got some ap, and shot a big ass lazar at everyone.
    2010 Jan 20 at 08:32
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5258
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.
Everyone stares when you walk in the room, they stare when you go....
    (Edited 2010 Jan 20 at 08:44)     2010 Jan 20 at 08:43
sprinkles

Chrome Whore
2009 Sep 6 • 2430
10 ₧
Cool, if you tell me what it means/does I might be able to emulate it in C#.
...then I got some ap, and shot a big ass lazar at everyone.
    2010 Jan 20 at 10:14

Pages: [1]
Forum and design copyright © 2008-2010 SuperJer.com