S
S
Shoyo2022-02-09 13:34:27
C++ / C#
Shoyo, 2022-02-09 13:34:27

How to add all numbers in txt file?

In WF, using textbox, I save several numbers in a txt file. How can I add them up and put the result into a string variable?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Satisfied IT, 2022-02-09
specialist @borisdenis

  • Read text file
  • Convert a string of numbers into an array of the desired type
  • Add numbers

V
Vasily Bannikov, 2022-02-09
@vabka

What exactly are you having trouble with?
Read file - File.ReadAllLines
Convert string to number to add - int.Parse or double.Parse, or any other Parse / TryParse. Well Convert in the end
Add in a loop or through Linq, I think you yourself will understand how
How to put the result in a variable, probably also clear

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question