❔ Trying to write to file of a Collatz Conjecture program
hello, complete beginner here. im trying to make a program that takes a random number and puts it through the collatz conjecture, then sends every number used in the collatz conjecture to a .txt file on a USB drive. (quite a mouthful, i know). ive got the part about the collatz conjecture done, but i cant write to a file; i tried using streamwrite and File.WriteAllLines with an array
3 Replies
values.Append(Convert.ToString(x));
does not do what you think it does
it does nothing, actually, in this instance
it returns a new list, it doesn't change values
i think you want values
to be a List<string>
:
and then you want to call Add
on values
:
in C#, an array cannot be "appended" to, it has a fixed size. you use List<T>
insteadthanks!
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.