Join Reynald Adolphe for an in-depth discussion in this video Using statement for efficiency, part of C# Best Practices for Developers.
- [Instructor] So, I'd like to talk about one more feature…that you should keep in mind when you are…incorporating best practices.…That is implementing the using statement.…And I'm not referring to the keyword using…at the first line here where it's used to import namespaces.…I'm referring to the keyword using…that handles and cleans up resources.…It's used to declare a scope to use our resources,…and then it disposes of them.…
It's generally good for stream and database connections.…And it essentially can take the place of work…that you would put into a finally block,…which is used to clean house.…I'm gonna go ahead and demonstrate what I'm referring to.…Let's say that I wanted to use filestream to open up a file.…Now, I have a file in my temp directory called theAgency…and it just has some repeated content in it.…
And we're gonna go ahead and use filestream to open it.…I'll start off by commenting out…our previous code…and typing filestream.…I'll hold control and period to import…the system.io namespace, and we'll type in fs1…
- Naming and handling classes
- Running a unit test
- Using constructors
- Naming and handling methods, fields, and properties
- Using properties correctly
- Managing objects efficiently
- Common design patterns as best practices
Skill Level Intermediate
1. Best Practices: An Overview
2. Naming and Handling Classes
3. Naming and Handling Methods, Fields, and Properties
4. Managing Objects Efficiently
5. More Best Practices Resources
- 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.