ok, so remove the parameter out BitArray Final_Result
and change your return type from void to BitArray
and instead of setting Final_result
use return
eg return bitArray_s
public BitArray SymbolNotInBracket(string FullpedX, char symbol)
{
bool flag;
byte starts = 0;
string new_ped = FullpedX;
Final_Result = new BitArray(FullpedX.Length, false);
int len = new_ped.Length;
BitArray bitArray_lb = new BitArray(new bool[FullpedX.Length]);
BitArray bitArray_rb = new BitArray(new bool[FullpedX.Length]);
BitArray bitArray_s = new BitArray(new bool[FullpedX.Length]);
symbol_index_numbers(new_ped, '[', out bitArray_lb);
symbol_index_numbers(new_ped, ']', out bitArray_rb);
symbol_index_numbers(new_ped, symbol, out bitArray_s);
if (bitArray_s.Cast<bool>().Any(x => x) && bitArray_lb.Cast<bool>().Any(x => x)) // if any contain true values
{
byte check_LB = 0;
for (check_LB = 0; check_LB < len; check_LB++)
if (bitArray_lb[check_LB] == true)
{
flag = false;
byte k = 0;
for (k = 0; k < len; k++)
{
if (bitArray_lb[k] == true)
{
starts = k;
flag = true;
}
else if (bitArray_rb[k] == true & flag)
{
bitArray_lb[starts] = false;
bitArray_rb[k] = false;
for (int z = starts; z < k; z++)
{
bitArray_s.Set(z, false);
}
flag = false;
}
}
}
if (bitArray_s.Cast<bool>().Any(x => x)) { return bitArray_s; }
}
else if (bitArray_s.Cast<bool>().Any(x => x))
{
return bitArray_s;
}
I didnt test this, it feels like a } may be missing, but you can see my point
by doing this, you can assign elements within an array, using the function (without needing a 'bucket' to store it in)
eg
array[0] = SymbolNotInBracket(pedigree, '<'); //this works now because the result of running SymbolNotInBracket returns an instance of a bit array