.NET 4.0 Generics Beginner's Guide
eBook - ePub

.NET 4.0 Generics Beginner's Guide

Sudipta Mukherjee

  1. 396 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfĂŒgbar
eBook - ePub

.NET 4.0 Generics Beginner's Guide

Sudipta Mukherjee

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

In Detail

Generics were added as part of .NET Framework 2.0 in November 2005. Although similar to generics in Java, .NET generics do not apply type erasure but every object has unique representation at run-time. There is no performance hit from runtime casts and boxing conversions, which are normally expensive..NET offers type-safe versions of every classical data structure and some hybrid ones.

This book will show you everything you need to start writing type-safe applications using generic data structures available in Generics API. You will also see how you can use several collections for each task you perform. This book is full of practical examples, interesting applications, and comparisons between Generics and more traditional approaches. Finally, each container is bench marked on the basis of performance for a given task, so you know which one to use and when.

This book first covers the fundamental concepts such as type safety, Generic Methods, and Generic Containers. As the book progresses, you will learn how to join several generic containers to achieve your goals and query them efficiently using Linq. There are short exercises in every chapter to boost your knowledge.

The book also teaches you some best practices, and several patterns that are commonly available in generic code.

Some important generic algorithm definitions are present in Power Collection (an API created by Wintellect Inc.) that are missing from .NET framework. This book shows you how to use such algorithms seamlessly with other generic containers.

The book also discusses C5 collections. Java Programmers will find themselves at home with this API. This is the closest to JCF. Some very interesting problems are solved using generic containers from .NET framework, C5, and PowerCollection Algorithms - a clone of Google Set and Gender Genie for example!

The author has also created a website (http://www.consulttoday.com/genguide) for the book where you can find many useful tools, code snippets, and, applications, which are not the part of code-download section

Approach

This is a concise, practical guide that will help you learn Generics in .NET, with lots of real world and fun-to-build examples and clear explanations. It is packed with screenshots to aid your understanding of the process.

Who this book is for

This book is aimed at beginners in Generics. It assumes some working knowledge of C# , but it isn't mandatory.

The following would get the most use out of the book:

  1. Newbie C# developers struggling with Generics.
  2. Experienced C++ and Java Programmers who are migrating to C# and looking for an alternative to other generic frameworks like STL and JCF would find this book handy. 
  3. Managers who want to know what Generics is and how to put it to good use.
  4. Architects will find the benchmarking extremely useful, because it's the first of its kind across a framework of several collections.

HĂ€ufig gestellte Fragen

Wie kann ich mein Abo kĂŒndigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kĂŒndigen“ – ganz einfach. Nachdem du gekĂŒndigt hast, bleibt deine Mitgliedschaft fĂŒr den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich BĂŒcher herunterladen?
Derzeit stehen all unsere auf MobilgerĂ€te reagierenden ePub-BĂŒcher zum Download ĂŒber die App zur VerfĂŒgung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die ĂŒbrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den AboplÀnen?
Mit beiden AboplÀnen erhÀltst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst fĂŒr LehrbĂŒcher, bei dem du fĂŒr weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhĂ€ltst. Mit ĂŒber 1 Million BĂŒchern zu ĂŒber 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
UnterstĂŒtzt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nÀchsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist .NET 4.0 Generics Beginner's Guide als Online-PDF/ePub verfĂŒgbar?
Ja, du hast Zugang zu .NET 4.0 Generics Beginner's Guide von Sudipta Mukherjee im PDF- und/oder ePub-Format sowie zu anderen beliebten BĂŒchern aus Computer Science & Programming in C#. Aus unserem Katalog stehen dir ĂŒber 1 Million BĂŒcher zur VerfĂŒgung.

Information

Jahr
2012
ISBN
9781849690782

.NET 4.0 Generics

Beginner's Guide


Table of Contents

.NET 4.0 Generics
Credits
Foreword
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Time for action – heading
What just happened?
Pop quiz – heading
Have a go hero – heading
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Why Generics?
An analogy
Reason 1: Generics can save you a lot of typing
Reason 2: Generics can save you type safety woes, big time
What's the problem with this approach?
Reason 3: Generics leads to faster code
Reason 4: Generics is now ubiquitous in the .NET ecosystem
Setting up the environment
Summary
2. Lists
Why bother learning about generic lists?
Types of generic lists
Checking whether a sequence is a palindrome or not
Time for action – creating the generic stack as the buffer
What just happened?
Time for action – completing the rest of the method
What just happened?
Designing a generic anagram finder
Time for action – creating the method
What just happened?
Have a go hero – use this method to find anagrams from a dictionary
Life is full of priorities, let's bring some order there
Time for action – creating the data structure for the prioritized shopping list
What just happened?
Time for action – let's add some gadgets to the list and see them
What just happened?
Time for action – let's strike off the gadgets with top-most priority after we have bought them
What just happened?
Time for action – let's create an appointment list
What just happened?
Live sorting and statistics for online bidding
Time for action – let's create a custom class for live sorting
What just happened?
Why did we have three LinkedList<T> as part of the data structure?
Pop quiz
An attempt to answer questions asked by your boss
Time for action – associating products with live sorted bid amounts
What just happened?
Time for action – finding common values across different bidding amount lists
What just happened?
Have a go hero – finding common demographic statistics for the bidders
You will win every scrabble game from now on
Time for action – creating the method to find the character histogram of a word
Time for action – checking whether a word can be formed
Time for action – let's see whether it works
Pop quiz
Have a go hero – explain the code!
Trying to fix an appointment with a doctor?
Time for action – creating a set of dates of the doctors' availability
What just happened?
Time for action – finding out when both doctors shall be present
What just happened?
Pop quiz
Revisiting the anagram problem
Time for action – re-creating the anagram finder
What just happened?
Lists under the hood
Summary
3. Dictionaries
Types of generic associative structures
Creating a tag cloud generator using dictionary
Time for action – creating the word histogram
What just happened?
Have a go hero
Pop quiz
Creating a bubble wrap popper game
Time for action – creating the game console
What just happened?
Look how easy it was!
How did we decide we need a dictionary and not a list?
Let's build a generic autocomplete service
Time for action – creating a custom dictionary for autocomplete
What just happened?
Time for action – creating a class for autocomplete
What just happened?
The most common pitfall. Don't fall there!
Let's play some piano
Time for action – creating the keys of the piano
What just happened?
How are we recording the key strokes?
Time for action – switching on recording and playing recorded keystrokes
How it works?
C# Dictionaries can help detect cancer. Let's see how!
Time for action – creating the KNN API
What just happened?
Time for action – getting the patient records
Time for action – creating the helper class to read a delimited file
What just happened?
Time for action – let's see how to use the predictor
What just happened?
Tuples are great for many occasions including games
Time for action – putting it all together
What just happened?
Why have we used Tuples?
How did we figure out whether the game is over or not?
Have a go hero
Summary
4. LINQ to Objects
What makes LINQ?
Extension methods
Time for action – creating an Extension method
What just happened?
Time for action – consuming our new Extension method
What just happened?
Check out these guidelines for when not to use Extension methods
Object initializers
Collection initializers
Implicitly typed local variables
Anonymous types
Lambda expressions
Functors
Predicates
Actions
Putting it all together, LINQ Standard Query Operators
Time for action – getting the LINQPad
Restricti...

Inhaltsverzeichnis

Zitierstile fĂŒr .NET 4.0 Generics Beginner's Guide

APA 6 Citation

Mukherjee, S. (2012). .NET 4.0 Generics Beginner’s Guide (1st ed.). Packt Publishing. Retrieved from https://www.perlego.com/book/388832/net-40-generics-beginners-guide-pdf (Original work published 2012)

Chicago Citation

Mukherjee, Sudipta. (2012) 2012. ..NET 4.0 Generics Beginner’s Guide. 1st ed. Packt Publishing. https://www.perlego.com/book/388832/net-40-generics-beginners-guide-pdf.

Harvard Citation

Mukherjee, S. (2012) .NET 4.0 Generics Beginner’s Guide. 1st edn. Packt Publishing. Available at: https://www.perlego.com/book/388832/net-40-generics-beginners-guide-pdf (Accessed: 14 October 2022).

MLA 7 Citation

Mukherjee, Sudipta. ..NET 4.0 Generics Beginner’s Guide. 1st ed. Packt Publishing, 2012. Web. 14 Oct. 2022.