This is my class I created:
public class FD
{
private char[] L;
private char[] R;
public char[] myL
{
get { return L; }
set { L = value; }
}
public char[] myR
{
get { return R; }
set { R = value; }
}
}
and my function:
public FD[] DetachedRight(FD element)
{
int count = element.myR.Length;
FD[] FDtemp = new FD[count];
char[] temp = element.myR;
char[] OneChar = new char[1];
for (int i = 0; i < count; i++)
{
FDtemp[i] = element;
OneChar[0] = temp[i];
FDtemp[i].myR(OneChar);
}
for (int j = 0; j < FDtemp.Length; j++)
{
MessageBox.Show(new string(FDtemp[j].myR()) + "==>" + new string(FDtemp[j].myR()), "Result");
}
return FDtemp;
}
This is what I want: Example: input (element parameter in code) with value element.myL = FD and element.myR = XYZ
I need: output is an array type FD, in example, it has 3 element in array:
FDtemp[0].myL = FD and FDtemp[0].myR = X;
FDtemp[1].myL = FD and FDtemp[1].myR = Y;
FDtemp[2].myL = FD and FDtemp[2].myR = Z;
In fact, the result I achieved: FDtemp[0] like FDtemp[1] like FDtemp[2], all .myL = FD, all .myR = Z
(value in last for loop).
Could you help me explain and solving this?
Combo: before, when I not use char[] temp = element.myR;
in my function, OneChar[0] = temp[i];
replece by OneChar[0] = element.myR[i];
, at second for loop, total length of element.myR
is 1, in my example, it is element.myR = "X", "XY"
not exist, why? I do not understand? Please help me explain that.