Join Gerry O'Brien for an in-depth discussion in this video Building functions that return a value, part of Learning C# (2014).
We can also ask a function to return values back to us.…And if that's the case, we have to indicate that we want the…values to be returned by indicating the data type that will be returned.…So let's go ahead and create a method that is exactly the same as the previous one.…We are going to concatenate two strings, but this case, we're…going to return a value, so we have to indicate a return type.…In this case, it will be string.…In this method of concatenate we'll actually end up being a little…more true to what we should be dealing with in terms of…discreet functionality because we're only going…to have, essentially, there'll be two…lines of coding here, but it's only going to do one thing.…
So, static string Concatenate.…Again, accepts the two arguments, first and last.…And right after that, Visual Studio is complaining with their little red…squiggly because it's saying, hey, not all code paths return a value.…That's fine, we'll fix that here in just a moment.…So, we'll use the same values that we used above, string whole…
- Installing C#
- Working with loops
- Controlling program flow
- Using variables
- Building functions
- Creating and instantiating classes
- Catching errors
- Managing resources with the garbage collector
- Building collections
Skill Level Beginner
1. Introducing C#
2. C# Language Elements
3. Object-Oriented Programming in C#
4. Structured Exception Handling
5. Resource Management in C#
6. Extensible Types in C#
7. Windows Apps in C#
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.