Intermediate C# Programming
2 day training course
Synopsis
Take your C# skills to the next level with this popular course bringing you right up to date with the latest C# features. This follow-on to our popular
Programming with C# course will introduce those with some C# experience to more advanced concepts such as generics, reflection, interfaces, indexers, and how to query collections with LINQ. It will also show you how to read/write data to/from a database using ADO.NET, or to/from XML. It will also cover Lists, lambda expressions, anonymous types, extension methods and more.
Duration
2 days
Cost
£650 plus VAT
Prerequisites
Delegates should have a working knowledge of C#, to the level provided by our
Programming with C# course. They certainly need to understand concepts such as classes, objects, methods and properties. If in doubt please contact us before booking.
Detailed course contents
Reflection and Custom Attributes
- What is reflection?
- The Type type
- Getting the Type of a class or object
- Using reflection to find out if a class is abstract or sealed
- Viewing a type’s properties and methods
- Other uses of reflection
- Custom attributes
- Uses of custom attributes
- Creating custom attributes
- Adding custom attributes to a class
- Viewing the custom attributes of a class
- Adding attribute properties
- Using an attribute with properties
- Adding attribute constructors
- Viewing more details about the attributes
Indexers
- What are Indexers?
- Declaring an Indexer
- Using indexers
- Overloaded Indexers
Generics
- What is generics?
- Uses for generics
- Flexibility using generics
- Substitution parameter naming convention
- Type safety with generics
- Using generics with a class
Lists
- Lists
- Creating a List
- foreach loop with a List
- Other supported methods and properties
Abstract behaviour in classes
- Preventing instantiation from a class
- Creating an abstract class
- Members of an abstract class
- Concrete and abstract methods
Interfaces
- What is an interface?
- Interface rules
- Inheriting from an interface
- Creating an interface
- Properties of an interface
- Methods in an interface
- Basing a class on an interface
- Basing an interface on an interface
- Multiple inheritance
- Interfaces as variable or parameter data types
- The IComparable and IComparable interfaces
Lambda Expressions
- Lambda Expressions
- Replacing a method with a lambda expression
Object Initializers
- C# Object Initializers
- C# Object Initializer syntax
- C# Object Initializer without constructor
- C# Object Initializer with constructor
Partial classes
Implicitly typed local variables with var
- Implicitly typed local variables
- var examples
Extension methods
- Extending a class without access to its code
- Using static behaviour
- Creating an extension method
Delegates
- What is a Delegate?
- Creating a Delegate
- Referencing a Method
- Using a delegate
- Multicasting
- Creating a Multicasting Delegate
- Scope
- Removing Method References
- Removing Method References - Multicasting
LINQ
- LINQ (Language INtegrated Query)
- LINQ queries
- How LINQ works
- The query variable
- LINQ query syntax
- The from clause
- The select clause
- Returning a customised data type
- The where clause
- The orderby clause
- The group clause
- The Single method
- Aggregate functions
- Aggregate functions where no arguments are required
- Aggregate functions where the object cannot be directly aggregated
LINQ extension methods
- Extension Methods in System.Linq
- Passing lambda expressions
- Where and OrderBy
- Combining methods
XML
- XML and .NET
- The System.Xml namespace
- Using XmlReader to read XML
- Using XmlWriter to create XML
- Using the DOM
- Using XmlDocument
- Using XmlDocument to create a new document
- Using XmlDocument to create a document from a file
- The GetElementsByTagName method
- The SelectNodes method
- Modifying an XML document
- LINQ and XML
- Creating XML with Linq
- Using LINQ to query XML
- Querying a sub-element
- Serialising objects into XML
- Default XML layout
- Customising the default XML layout
- Modifying XML output without access to the class code
- Changing the name of the root element
- Deserialising XML to an object
- Class name different from the name of the root element
Connected data access with ADO.NET
- What is ADO.NET?
- ADO.NET namespaces
- High level data access process
- Creating a connection object
- Storing connection strings in config files
- Command objects
- CommandType and CommandText
- Command object methods
- Disposing of resources
- The using statement
- ExecuteNonQuery
- ExecuteScalar
- ExecuteReader
- Data readers
- Using a Data Reader
- Cleaning up after data readers
- Command parameters
- Adding parameters to commands
- A command with parameters
ADO.NET disconnected data access
- The DataTable Object
- The DataColumn object
- The DataRow object
- Manually creating and filling a datatable
- The Rows collection
- The Columns collection
- The DataSet object
- Data adapters
- Data adapter properties
- Working with data locally
- Filling a DataTable with a data adapter
Error handling
- Review of basic exception handling (try .. catch.. finally)
- The Exception Class
- Catching the Exception instance
- The Exception Message
- More error handling
- Basic Exception Handling
- try .. catch
- finally
- The Exception Class
- Catching the Exception instance
- The Exception Message
- Derived Exception Classes
- FormatException
- OverflowException
- IndexOutOfRangeException
- DivideByZeroException
- Catching Multiple Exceptions
- Exception Nesting
- Throwing an Exception
- Passing a message to the Exception class
- Custom Exceptions
- Defining Custom Exceptions
- Throwing custom Exceptions
- Custom Exception with constructor
- Throwing a custom exception whose constructor takes arguments