Skip to end of metadata
Go to start of metadata

This task was to explore C# I/O. I let the user type in text, type it back to them, read and print file contents, and let the user append text to it, just like in my C++ program. Here is a snippet of the code I used to do that:

Does your language have built-in support for I/O, or is it part of a set of standard libraries?

The standard system library is necessary for I/O.

Does your language support different types of files, such as binary v. text files?

Yes; you can read binary by storing in a list of bytes the result of File.ReadAllBytes() on the input file's name. Then, use .ToString() when printing.

Can the user input information into the program interactively?

Yes, just use Console.ReadLine();

What is the relationship between files and strings? Demonstrate similarities and differences in the way the programming language handles them.

C# treats files like classes. Strings are objects, and are stored as sequences of char objects.You can use String or string interchangeably with the same available methods.

 

 

Labels
  • No labels