C
C#2y ago
tadeusz.

❔ data[].W_tektście does change even if I didn't use this variable in the Method


static void Main(string[] args)
{
Data[] text;

name = a;
text = Read(źródło, 1, 100);
text = Trajektorja(text);
name = "C:\\Users\\******\\Desktop\\"+name+".txt";
File.WriteAllLines(@name, Data.SuperLinia(text));
}
private static Data[] Trajektorja(Data[] text)
{
int k = text.Length;
for (int i = 0; i < k; i++)
{
Console.WriteLine(text[i].W_tektście);
text[i].dane = Trajektorja(text, i);
Console.WriteLine(text[i].W_tektście);
}
name += "_Power";
return text;
}
private static double Trajektorja(Data[] txt, int i)
{
double sum = 0;
i++;
txt = Sort(txt, i);
double a = i * i + i;
for (int j = 0; j < i; j++)
{
txt[j].GetmanyData(); //Convert string of DD.MM.YYYY hh:mm into many int
txt[j].DataNaLiczby(); //Convert D, M, Y, h and m into a number value double
sum += (i - 1 - 2 * j)/a * txt[j].Ilość_dni;
}
Console.WriteLine(txt[i-1].W_tektście);
return sum;
}

static void Main(string[] args)
{
Data[] text;

name = a;
text = Read(źródło, 1, 100);
text = Trajektorja(text);
name = "C:\\Users\\******\\Desktop\\"+name+".txt";
File.WriteAllLines(@name, Data.SuperLinia(text));
}
private static Data[] Trajektorja(Data[] text)
{
int k = text.Length;
for (int i = 0; i < k; i++)
{
Console.WriteLine(text[i].W_tektście);
text[i].dane = Trajektorja(text, i);
Console.WriteLine(text[i].W_tektście);
}
name += "_Power";
return text;
}
private static double Trajektorja(Data[] txt, int i)
{
double sum = 0;
i++;
txt = Sort(txt, i);
double a = i * i + i;
for (int j = 0; j < i; j++)
{
txt[j].GetmanyData(); //Convert string of DD.MM.YYYY hh:mm into many int
txt[j].DataNaLiczby(); //Convert D, M, Y, h and m into a number value double
sum += (i - 1 - 2 * j)/a * txt[j].Ilość_dni;
}
Console.WriteLine(txt[i-1].W_tektście);
return sum;
}
The text[i].W_tektście change into txt.[i].W_tektście and because txt was sorted, it is not the same string value. Sort(Data[] name, int size) sort name.czas_solv from smallest to biggest and additionaly change name.W_tektście place according to name.czas_solv. I checked the value of sum/text.dane and they are in correct order. Why does the second Trajektorja change text.W_tektście even if it return a double value sum?
1 Reply
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity. Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.