title: “Exploring Built-In Functions” —
The C# language actually has a lot of built-in functionality in the form of classes and functions. We’ll talk more about Classes in the next lesson.
But let’s explore some of the built-in functions that are available to us!
There are lots of interesting things you can do with strings, such as analyzing user input text.
Go find the C# documenation for strings, and learn about the following string functions:
For instance, you could write a program that tells you whether an input string contains the word “banana”;
Here’s a bit of code that will open a browser window to a webpage the user specifies:
Here’s a bit of code that will load the contents of a text file from a particular location on the hard drive, and print the contents to the console:
You can use File.ReadAllLines to read all of the text out of a file.
C# comes with a whole library of math functions called MathF. For instance, here’s a function to compute the area of a circle given its radius, using the MathF.PI variable:
Not sure how to do a particular thing in code? Chances are, there are samples out on the internet! One of the most important skills you’ll develop as a programmer is figuring out how to find existing solutions for problems.
Google is your friend!