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


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


2007 Oct 19 • 5258
57,583 ₧
|
|
|
|
|
|
2010 Jan 19 at 11:00
|
|
|
sprinkles


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


2007 Oct 19 • 5258
57,583 ₧
|
|
|
|
|
|
2010 Jan 19 at 12:48
|
|
|
sprinkles


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


2007 Oct 19 • 5258
57,583 ₧
|
|
|
|
|
|
2010 Jan 20 at 03:26
|
|
|
sprinkles


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


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


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


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]
|