From the course: Advanced C#: Functional Programming Patterns

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Work with files

Work with files

- [Narrator] In prior discussions, we've talked about the difference between a pure function and an impure function. One of the principles of functional programming states that if you do any sort of IO work, like working with a database, opening a network socket, working with a console, reading and writing from the console whindow, or what I'm showing in this example, opening and pulling information out of a file. That is IO, and that has a side effect, so therefore, we should strive to move that impure code, that side effect code, into its own separate function. And then we call that function, it does the work of opening that file, and retrieving the information. Once we have the information, we pass that into the pure function, where it does its calculation or computation. So for this example, we're going to be opening a XML file and reading the contents. So let's take a look at this RobotNames.xml file. Root…

Contents