From the course: Learning C#
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Returning multiple values - C# Tutorial
From the course: Learning C#
Returning multiple values
- [Instructor] As we saw in a previous video, sometimes it's desirable to return more than one value from a function. So the problem is that functions can only have one return value. So the C# language has something called an out keyword that lets you return values in normal function parameters. Now, unfortunately that sometimes leads to code that is hard to read, and it also kind of breaks the convention that parameters are used to give data to functions and return values are used to get results back. So starting back in C# version seven, Microsoft added support for a data type known as a tuple. A tuple is basically a lightweight data structure that lets you group multiple values together in one place. So let's open up our sample code here in the MultiValues folder in our functions folder, and let's take a look at a basic tuple. It looks something like this. So inside parentheses, which is what you use to group tuple…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.