I’m still rather new to the c# programming, so I was trying to make a class method.
But it won’t work.
So what do I want to do:
I get some string that has in the name a var. x and y number.
The string for example will be like this: “x02y42”
So I want to have a function inside my application (wpf window) where I can send that string back, and get 2 doubles returned like: “double = 02” and “double = 42” (so not as strings).
So I made a new class,
and within this class I have made this code:
public double x,y(string parm)
{
//input shall be: string s = x12y04;
//inp s looks like x12y04
//splut the string on the Y (so this tech should also work for x89232y329)
//so this will create res[0] that is x89232 and an res[1] that is 329
string[] res = parm.Split(new string[] { "y" }, StringSplitOptions.RemoveEmptyEntries);
//now for the x in res[0], we replace it for a 0 so it are all numbers
string resx = res[0].Replace("x", "0");
//now we will get the strings to doubles so we can really start using them.
double x = double.Parse(resx);
double y = double.Parse(res[1]);
//get the values back
return x, y;
}
Now (ofc) it did not work.
But as stated above, I am still pretty new to c#.
So what am I doing wrong here?
I can put this in 1 function right?
So that within my application I can call it somehow?
You would have to return an array containing the two values. E.g: