Skip to Main Content
Visual Basic 2015 Unleashed
book

Visual Basic 2015 Unleashed

by Alessandro Del Sole
July 2015
Intermediate to advanced content levelIntermediate to advanced
1300 pages
87h 27m
English
Sams
Content preview from Visual Basic 2015 Unleashed

Understanding Constraints

With constraints, you can control the behavior of generics and provide additional functionalities and limit the implementation to specific data types. Let’s begin by understanding constraints on methods.

Methods Constraints

Imagine you want the ability to compare two items within an array. To accomplish this, you need to take advantage of the IComparable interface, and because of this, you want to require that the type argument implements the IComparable interface. The following code demonstrates this:

Public Function CompareItems(Of T As IComparable)(sourceArray() As T,                                                  index1 As Integer,                                                  index2 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Visual Basic 2015

Beginning Visual Basic 2015

Bryan Newsome

Publisher Resources

ISBN: 9780134196664Purchase book