Microsoft Visual C Step By Step Ninth Edition John Sharp
Microsoft Visual C Step By Step Ninth Edition John Sharp
Microsoft Visual C Step By Step Ninth Edition John Sharp
Microsoft Visual C Step By Step Ninth Edition John Sharp
Microsoft Visual C Step By Step Ninth Edition John Sharp
1.
Microsoft Visual CStep By Step Ninth Edition
John Sharp download
https://ebookbell.com/product/microsoft-visual-c-step-by-step-
ninth-edition-john-sharp-50195198
Explore and download more ebooks at ebookbell.com
2.
Here are somerecommended products that we believe you will be
interested in. You can click the link to download.
Microsoft Visual C Step By Step Tenth John Sharp
https://ebookbell.com/product/microsoft-visual-c-step-by-step-tenth-
john-sharp-49597660
Microsoft Visual C Step By Step 8th Edition John Sharp
https://ebookbell.com/product/microsoft-visual-c-step-by-step-8th-
edition-john-sharp-5559712
Microsoft Visual C Step By Step 9th John Sharp
https://ebookbell.com/product/microsoft-visual-c-step-by-step-9th-
john-sharp-7220368
Microsoft Visual C Step By Step Developer Reference Sharp John
https://ebookbell.com/product/microsoft-visual-c-step-by-step-
developer-reference-sharp-john-35047772
3.
Microsoft Visual CStep By Step Developer Reference Sharp John
Chenjin5com
https://ebookbell.com/product/microsoft-visual-c-step-by-step-
developer-reference-sharp-john-chenjin5com-36191964
Build Windows 8 Apps With Microsoft Visual C Step By Step Regnicoli L
https://ebookbell.com/product/build-windows-8-apps-with-microsoft-
visual-c-step-by-step-regnicoli-l-6443092
Microsoft Visual C 2010 Step By Step John Sharp
https://ebookbell.com/product/microsoft-visual-c-2010-step-by-step-
john-sharp-2310048
Microsoft Visual C 2013 Step By Step John Sharp
https://ebookbell.com/product/microsoft-visual-c-2013-step-by-step-
john-sharp-37706228
Microsoft Visual C 2012 Step By Step John Sharp
https://ebookbell.com/product/microsoft-visual-c-2012-step-by-step-
john-sharp-4071100
Special Sales
For informationabout buying this title in bulk quantities, or for special sales
opportunities (which may include electronic versions; custom cover designs; and
content particular to your business, training goals, marketing focus, or branding
interests), please contact our corporate sales department at
corpsales@pearsoned.com or (800) 382-3419.
For government sales inquiries, please contact
governmentsales@pearsoned.com.
For questions about sales outside the U.S., please contact intlcs@pearson.com.
Editor-in-Chief
Contents at aGlance
Acknowledgments
About the Author
Introduction
PART I INTRODUCING MICROSOFT VISUAL C# AND
MICROSOFT VISUAL STUDIO 2017
CHAPTER 1 Welcome to C#
CHAPTER 2 Working with variables, operators, and expressions
CHAPTER 3 Writing methods and applying scope
CHAPTER 4 Using decision statements
CHAPTER 5 Using compound assignment and iteration statements
CHAPTER 6 Managing errors and exceptions
PART II UNDERSTANDING THE C# OBJECT MODEL
CHAPTER 7 Creating and managing classes and objects
CHAPTER 8 Understanding values and references
CHAPTER 9 Creating value types with enumerations and structures
CHAPTER 10 Using arrays
CHAPTER 11 Understanding parameter arrays
CHAPTER 12 Working with inheritance
CHAPTER 13 Creating interfaces and defining abstract classes
CHAPTER 14 Using garbage collection and resource management
PART III DEFINING EXTENSIBLE TYPES WITH C#
22.
CHAPTER 15 Implementingproperties to access fields
CHAPTER 16 Handling binary data and using indexers
CHAPTER 17 Introducing generics
CHAPTER 18 Using collections
CHAPTER 19 Enumerating collections
CHAPTER 20 Decoupling application logic and handling events
CHAPTER 21 Querying in-memory data by using query expressions
CHAPTER 22 Operator overloading
PART IV BUILDING UNIVERSAL WINDOWS PLATFORM
APPLICATIONS WITH C#
CHAPTER 23 Improving throughput by using tasks
CHAPTER 24 Improving response time by performing asynchronous operations
CHAPTER 25 Implementing the user interface for a Universal Windows
Platform app
CHAPTER 26 Displaying and searching for data in a Universal Windows
Platform app
CHAPTER 27 Accessing a remote database from a Universal Windows Platform
app
Index
23.
Contents
Acknowledgments
About the Author
Introduction
PARTI INTRODUCING MICROSOFT VISUAL C# AND
MICROSOFT VISUAL STUDIO 2017
Chapter 1 Welcome to C#
Beginning programming with the Visual Studio 2017 environment
Writing your first program
Using namespaces
Creating a graphical application
Examining the Universal Windows Platform app
Adding code to the graphical application
Summary
Quick reference
Chapter 2 Working with variables, operators, and expressions
Understanding statements
Using identifiers
Identifying keywords
Using variables
Naming variables
Declaring variables
Specifying numeric values
Working with primitive data types
Unassigned local variables
24.
Displaying primitive datatype values
Using arithmetic operators
Operators and types
Examining arithmetic operators
Controlling precedence
Using associativity to evaluate expressions
Associativity and the assignment operator
Incrementing and decrementing variables
Prefix and postfix
Declaring implicitly typed local variables
Summary
Quick reference
Chapter 3 Writing methods and applying scope
Creating methods
Declaring a method
Returning data from a method
Using expression-bodied methods
Calling methods
Specifying the method call syntax
Returning multiple values from a method
Applying scope
Defining local scope
Defining class scope
Overloading methods
Writing methods
Refactoring code
Nesting methods
Using optional parameters and named arguments
Defining optional parameters
Passing named arguments
25.
Resolving ambiguities withoptional parameters and named
arguments
Summary
Quick reference
Chapter 4 Using decision statements
Declaring Boolean variables
Using Boolean operators
Understanding equality and relational operators
Understanding conditional logical operators
Short-circuiting
Summarizing operator precedence and associativity
Using if statements to make decisions
Understanding if statement syntax
Using blocks to group statements
Cascading if statements
Using switch statements
Understanding switch statement syntax
Following the switch statement rules
Summary
Quick reference
Chapter 5 Using compound assignment and iteration statements
Using compound assignment operators
Writing while statements
Writing for statements
Understanding for statement scope
Writing do statements
Summary
Quick reference
Chapter 6 Managing errors and exceptions
26.
Coping with errors
Tryingcode and catching exceptions
Unhandled exceptions
Using multiple catch handlers
Catching multiple exceptions
Filtering exceptions
Propagating exceptions
Using checked and unchecked integer arithmetic
Writing checked statements
Writing checked expressions
Throwing exceptions
Using throw exceptions
Using a finally block
Summary
Quick reference
PART II UNDERSTANDING THE C# OBJECT MODEL
Chapter 7 Creating and managing classes and objects
Understanding classification
The purpose of encapsulation
Defining and using a class
Controlling accessibility
Working with constructors
Overloading constructors
Deconstructing an object
Understanding static methods and data
Creating a shared field
Creating a static field by using the const keyword
Understanding static classes
Static using statements
27.
Anonymous classes
Summary
Quick reference
Chapter8 Understanding values and references
Copying value type variables and classes
Understanding null values and nullable types
The null-conditional operator
Using nullable types
Understanding the properties of nullable types
Using ref and out parameters
Creating ref parameters
Creating out parameters
How computer memory is organized
Using the stack and the heap
The System.Object class
Boxing
Unboxing
Casting data safely
The is operator
The as operator
The switch statement revisited
Summary
Quick reference
Chapter 9 Creating value types with enumerations and structures
Working with enumerations
Declaring an enumeration
Using an enumeration
Choosing enumeration literal values
Choosing an enumeration’s underlying type
Working with structures
28.
Declaring a structure
Understandingdifferences between structures and classes
Declaring structure variables
Understanding structure initialization
Copying structure variables
Summary
Quick reference
Chapter 10 Using arrays
Declaring and creating an array
Declaring array variables
Creating an array instance
Populating and using an array
Creating an implicitly typed array
Accessing an individual array element
Iterating through an array
Passing arrays as parameters and return values for a method
Copying arrays
Using multidimensional arrays
Creating jagged arrays
Accessing arrays that contain value types
Summary
Quick reference
Chapter 11 Understanding parameter arrays
Overloading—a recap
Using array arguments
Declaring a params array
Using params object[ ]
Using a params array
Comparing parameter arrays and optional parameters
29.
Summary
Quick reference
Chapter 12Working with inheritance
What is inheritance?
Using inheritance
The System.Object class revisited
Calling base-class constructors
Assigning classes
Declaring new methods
Declaring virtual methods
Declaring override methods
Understanding protected access
Creating extension methods
Summary
Quick reference
Chapter 13 Creating interfaces and defining abstract classes
Understanding interfaces
Defining an interface
Implementing an interface
Referencing a class through its interface
Working with multiple interfaces
Explicitly implementing an interface
Interface restrictions
Defining and using interfaces
Abstract classes
Abstract methods
Sealed classes
Sealed methods
Implementing and using an abstract class
Summary
30.
Quick reference
Chapter 14Using garbage collection and resource management
The life and times of an object
Writing destructors
Why use the garbage collector?
How does the garbage collector work?
Recommendations
Resource management
Disposal methods
Exception-safe disposal
The using statement and the IDisposable interface
Calling the Dispose method from a destructor
Implementing exception-safe disposal
Summary
Quick reference
PART III DEFINING EXTENSIBLE TYPES WITH C#
Chapter 15 Implementing properties to access fields
Implementing encapsulation by using methods
What are properties?
Using properties
Read-only properties
Write-only properties
Property accessibility
Understanding the property restrictions
Declaring interface properties
Replacing methods with properties
Generating automatic properties
Initializing objects by using properties
31.
Summary
Quick reference
Chapter 16Handling binary data and using indexers
What is an indexer?
Storing binary values
Displaying binary values
Manipulating binary values
Solving the same problems using indexers
Understanding indexer accessors
Comparing indexers and arrays
Indexers in interfaces
Using indexers in a Windows application
Summary
Quick reference
Chapter 17 Introducing generics
The problem: Misusing with the object type
The generics solution
Generics vs. generalized classes
Generics and constraints
Creating a generic class
The theory of binary trees
Building a binary tree class by using generics
Creating a generic method
Defining a generic method to build a binary tree
Variance and generic interfaces
Covariant interfaces
Contravariant interfaces
Summary
Quick reference
32.
Chapter 18 Usingcollections
What are collection classes?
The List<T> collection class
The LinkedList<T> collection class
The Queue<T> collection class
The Stack<T> collection class
The Dictionary<TKey, TValue> collection class
The SortedList<TKey, TValue> collection class
The HashSet<T> collection class
Using collection initializers
The Find methods, predicates, and lambda expressions
The forms of lambda expressions
Comparing arrays and collections
Using collection classes to play cards
Summary
Quick reference
Chapter 19 Enumerating collections
Enumerating the elements in a collection
Manually implementing an enumerator
Implementing the IEnumerable interface
Implementing an enumerator by using an iterator
A simple iterator
Defining an enumerator for the Tree<TItem> class by using
an iterator
Summary
Quick reference
Chapter 20 Decoupling application logic and handling events
Understanding delegates
Examples of delegates in the .NET Framework class library
The automated factory scenario
33.
Implementing the factorycontrol system without using
delegates
Implementing the factory by using a delegate
Declaring and using delegates
Lambda expressions and delegates
Creating a method adapter
Enabling notifications by using events
Declaring an event
Subscribing to an event
Unsubscribing from an event
Raising an event
Understanding user interface events
Using events
Summary
Quick reference
Chapter 21 Querying in-memory data by using query expressions
What is LINQ?
Using LINQ in a C# application
Selecting data
Filtering data
Ordering, grouping, and aggregating data
Joining data
Using query operators
Querying data in Tree<TItem> objects
LINQ and deferred evaluation
Summary
Quick reference
Chapter 22 Operator overloading
Understanding operators
Operator constraints
34.
Overloaded operators
Creating symmetricoperators
Understanding compound assignment evaluation
Declaring increment and decrement operators
Comparing operators in structures and classes
Defining operator pairs
Implementing operators
Understanding conversion operators
Providing built-in conversions
Implementing user-defined conversion operators
Creating symmetric operators, revisited
Writing conversion operators
Summary
Quick reference
PART IV BUILDING UNIVERSAL WINDOWS PLATFORM
APPLICATIONS WITH C#
Chapter 23 Improving throughput by using tasks
Why perform multitasking by using parallel processing?
The rise of the multicore processor
Implementing multitasking by using the Microsoft .NET Framework
Tasks, threads, and the ThreadPool
Creating, running, and controlling tasks
Using the Task class to implement parallelism
Abstracting tasks by using the Parallel class
When not to use the Parallel class
Canceling tasks and handling exceptions
The mechanics of cooperative cancellation
Using continuations with canceled and faulted tasks
Summary
35.
Quick reference
Chapter 24Improving response time by performing asynchronous
operations
Implementing asynchronous methods
Defining asynchronous methods: The problem
Defining asynchronous methods: The solution
Defining asynchronous methods that return values
Asynchronous method gotchas
Asynchronous methods and the Windows Runtime APIs
Tasks, memory allocation, and efficiency
Using PLINQ to parallelize declarative data access
Using PLINQ to improve performance while iterating
through a collection
Canceling a PLINQ query
Synchronizing concurrent access to data
Locking data
Synchronization primitives for coordinating tasks
Canceling synchronization
The concurrent collection classes
Using a concurrent collection and a lock to implement
thread-safe data access
Summary
Quick reference
Chapter 25 Implementing the user interface for a Universal Windows
Platform app
Features of a Universal Windows Platform app
Using the Blank App template to build a Universal Windows
Platform app
Implementing a scalable user interface
Applying styles to a UI
Summary
36.
Quick reference
Chapter 26Displaying and searching for data in a Universal Windows
Platform app
Implementing the Model–View–ViewModel pattern
Displaying data by using data binding
Modifying data by using data binding
Using data binding with a ComboBox control
Creating a ViewModel
Adding commands to a ViewModel
Searching for data using Cortana
Providing a vocal response to voice commands
Summary
Quick reference
Chapter 27 Accessing a remote database from a Universal Windows
Platform app
Retrieving data from a database
Creating an entity model
Creating and using a REST web service
Inserting, updating, and deleting data through a REST web service
Reporting errors and updating the UI
Summary
Quick reference
Index
37.
Acknowledgments
Well, here weare again, in what appears to have become a biennial event;
such is the pace of change in the world of software development! As I glance at
my beloved first edition of Kernighan and Ritchie describing The C
Programming Language (Prentice Hall), I occasionally get nostalgic for the old
times. In those halcyon days, programming had a certain mystique, even
glamour. Nowadays, in one form or another, the ability to write at least a little
bit of code is fast becoming as much a requirement in many workplaces as the
ability to read, write, or add up. The romance has gone, to be replaced by an air
of “everyday-ness.” Then, as I start to hanker after the time when I still had hair
on my head and the corporate mainframe required a team of full-time support
staff just to pander to its whims, I realize that if programming were restricted to
a few elite souls, then the market for C# books would have disappeared after the
first couple of editions of this tome. Thus cheered, I power up my laptop, my
mind mocking the bygone era when such processing power could have navigated
many hundreds of Apollo spacecraft simultaneously to the moon and back, and
get down to work on the latest edition of this book!
Despite the fact that my name is on the cover, authoring a book such as this is
far from a one-man project. I’d like to thank the following people who have
provided unstinting support and assistance throughout this exercise.
First, Trina MacDonald at Person Education, who took on the role of
prodding me into action and ever-so-gently tying me down to well-defined
deliverables and hand-off dates. Without her initial impetus and cajoling, this
project would not have got off the ground.
Next, Rick Kughen, the tireless copy editor who ensured that my grammar
remained at least semi-understandable, and picked up on the missing words and
nonsense phrases in the text.
Then, David Franson, who had the unenviable task of testing the code and
exercises. I know from experience that this can be a thankless and frustrating
task at times, but the hours spent and the feedback that results can only make for
a better book. Of course, any errors that remain are entirely my responsibility,
38.
a better book.Of course, any errors that remain are entirely my responsibility,
and I am happy to listen to feedback from any reader.
As ever, I must also thank Diana, my better half, who keeps me supplied with
caffeine-laden hot drinks when deadlines are running tight. Diana has been long-
suffering and patient, and has so far survived my struggle through nine editions
of this book; that is dedication well beyond the call of duty. She has recently
taken up running. I assumed it was to keep fit, but I think it is more likely so she
can get well away from the house and scream loudly without my hearing her!
And lastly, to James and Frankie, who have both now flown the nest. James
is trying to avoid gaining a Yorkshire accent while living and working in
Sheffield, but Frankie has remained closer to home so she can pop in and raid
the kitchen from time to time.
39.
About the Author
JohnSharp is a principal technologist for CM Group Ltd, a software
development and consultancy company in the United Kingdom. He is well
versed as a software consultant, developer, author, and trainer, with more than
35 years of experience, ranging from Pascal programming on CP/M and
C/Oracle application development on various flavors of UNIX to the design of
C# and JavaScript distributed applications and development on Windows 10 and
Microsoft Azure. He also spends much of his time writing courseware for
Microsoft, focusing on areas such as Data Science using R and Python, Big Data
processing with Spark and CosmosDB, and scalable application architecture
with Azure.
40.
Introduction
Microsoft Visual C#is a powerful but simple language aimed primarily at
developers who create applications built on the Microsoft .NET Framework.
Visual C# inherits many of the best features of C++ and Microsoft Visual Basic
but few of the inconsistencies and anachronisms, which results in a cleaner and
more logical language.
C# 1.0 made its public debut in 2001.
C# 2.0, with Visual Studio 2005, provided several important new features,
including generics, iterators, and anonymous methods.
C# 3.0, which was released with Visual Studio 2008, added extension
methods, lambda expressions, and most famously of all, the Language-
Integrated Query facility, or LINQ.
C# 4.0 was released in 2010 and provided further enhancements that
improved its interoperability with other languages and technologies. These
features included support for named and optional arguments and the
dynamic type, which indicates that the language runtime should implement
late binding for an object. An important addition to the .NET Framework,
and released concurrently with C# 4.0, were the classes and types that
constitute the Task Parallel Library (TPL). Using the TPL, you can build
highly scalable applications that can take full advantage of multicore
processors.
C# 5.0 added native support for asynchronous task-based processing
through the async method modifier and the await operator.
C# 6.0 was an incremental upgrade with features designed to make life
simpler for developers. These features include items such as string
interpolation (you need never use String.Format again!), enhancements to
the ways in which properties are implemented, expression-bodied
methods, and others.
C# 7.0 adds further enhancements to aid productivity and remove some of
the minor anachronisms of C#. For example, you can now implement
41.
property accessors asexpression-bodied members, methods can return
multiple values in the form of tuples, the use of out parameters has been
simplified, and switch statements have been extended to support pattern-
and type-matching. There are other updates as well, which are covered in
this book.
It goes without saying that Microsoft Windows 10 is an important platform
for running C# applications, but now you can also run code developed by using
C# on other operating systems, such as Linux, through the .NET Core runtime.
This opens up possibilities for writing code that can run in multiple
environments. Additionally, Windows 10 supports highly interactive
applications that can share data and collaborate as well as connect to services
running in the cloud. The key notion in Windows 10 is Universal Windows
Platform (UWP) apps—applications designed to run on any Windows 10 device,
whether a fully fledged desktop system, a laptop, a tablet, or even an IoT
(Internet of Things) device with limited resources. Once you have mastered the
core features of C#, gaining the skills to build applications that can run on all
these platforms is important.
Voice activation is another feature that has come to the fore, and Windows 10
includes Cortana, your personal voice-activated digital assistant. You can
integrate your own apps with Cortana to allow them to participate in data
searches and other operations. Despite the complexity normally associated with
natural-language speech analysis, enabling your apps to respond to Cortana’s
requests is surprisingly easy; I cover this in Chapter 26. Also, the cloud has
become such an important element in the architecture of many systems—ranging
from large-scale enterprise applications to mobile apps running on portable
devices—that I decided to focus on this aspect of development in the final
chapter of the book.
The development environment provided by Visual Studio 2017 makes these
features easy to use, and the many new wizards and enhancements included in
the latest version of Visual Studio can greatly improve your productivity as a
developer. I hope you have as much fun working through this book as I had
writing it!
Who should read this book
This book assumes that you are a developer who wants to learn the fundamentals
of programming with C# by using Visual Studio 2017 and the .NET Framework
42.
of programming withC# by using Visual Studio 2017 and the .NET Framework
version 4.6.1. By the time you complete this book, you will have a thorough
understanding of C# and will have used it to build responsive and scalable
applications that can run on the Windows 10 operating system.
Who should not read this book
This book is aimed at developers new to C# but not completely new to
programming. As such, it concentrates primarily on the C# language. This book
is not intended to provide detailed coverage of the multitude of technologies
available for building enterprise-level and global applications for Windows, such
as ADO.NET, ASP.NET, Azure, or Windows Communication Foundation. If
you require more information on any of these items, you might consider reading
some of the other titles available from Microsoft Press.
Organization of this book
This book is divided into four sections:
Part I, “Introducing Microsoft Visual C# and Microsoft Visual Studio
2017,” provides an introduction to the core syntax of the C# language and
the Visual Studio programming environment.
Part II, “Understanding the C# object model,” goes into detail on how to
create and manage new types in C# and how to manage the resources
referenced by these types.
Part III, “Defining extensible types with C#,” includes extended coverage
of the elements that C# provides for building types that you can reuse
across multiple applications.
Part IV, “Building Universal Windows Platform applications with C#,”
describes the universal Windows 10 programming model and how you can
use C# to build interactive applications for this model.
Finding your best starting point in this book
This book is designed to help you build skills in a number of essential areas. You
can use this book if you are new to programming or if you are switching from
another programming language such as C, C++, Java, or Visual Basic. Use the
43.
another programming languagesuch as C, C++, Java, or Visual Basic. Use the
following table to find your best starting point.
If you are Follow these steps
New to object-oriented
programming
1. Install the practice files as described in the
upcoming section, “Code samples.”
2. Work through the chapters in Parts I, II, and
III sequentially.
3. Complete Part IV as your level of experience
and interest dictates.
Familiar with procedural
programming languages,
such as C, but new to C#
1. Install the practice files as described in the
upcoming section, “Code samples.”
2. Skim the first five chapters to get an overview
of C# and Visual Studio 2017, and then
concentrate on Chapters 6 through 22.
3. Complete Part IV as your level of experience
and interest dictates.
Migrating from an object-
oriented language such as
C++ or Java
1. Install the practice files as described in the
upcoming section, “Code samples.”
2. Skim the first seven chapters to get an
overview of C# and Visual Studio 2017, and
then concentrate on Chapters 8 through 22.
3. For information about building Universal
Windows Platform applications, read Part IV.
Switching from Visual
Basic to C#
1. Install the practice files as described in the
upcoming section, “Code samples.”
2. Work through the chapters in Parts I, II, and
III sequentially.
3. For information about building Universal
Windows Platform applications, read Part IV.
4. Read the Quick Reference sections at the end
of the chapters for information about specific
C# and Visual Studio 2017 constructs.
Referencing the book after
working through the
1. Use the index or the table of contents to find
information about particular subjects.
44.
working through the
exercises
informationabout particular subjects.
2. Read the Quick Reference sections at the end
of each chapter to find a brief review of the
syntax and techniques presented in the chapter.
Most of the book’s chapters include hands-on samples that let you try out the
concepts you just learned. No matter which sections you choose to focus on, be
sure to download and install the sample applications on your system.
Conventions and features in this book
This book presents information by using conventions designed to make the
information readable and easy to follow.
Each exercise consists of a series of tasks, presented as numbered steps (1,
2, and so on) listing each action you must take to complete the exercise.
Boxed elements with labels such as “Note” provide additional information
or alternative methods for completing a step successfully.
Text that you type (apart from code blocks) appears in bold.
A plus sign (+) between two key names means that you must press those
keys at the same time. For example, “Press Alt+Tab” means that you hold
down the Alt key while you press the Tab key.
System requirements
You will need the following hardware and software to complete the practice
exercises in this book:
Windows 10 (Home, Professional, Education, or Enterprise) version 1507
or higher.
The most recent build of Visual Studio Community 2017, Visual Studio
Professional 2017, or Visual Studio Enterprise 2017 (make sure that you
have installed any updates). As a minimum, you should select the
following workloads when installing Visual Studio 2017:
• Universal Windows Platform development
• .NET desktop development
45.
• .NET desktopdevelopment
• ASP.NET and web development
• Azure development
• Data storage and processing
• .NET Core cross-platform development
Note All the exercises and code samples in this book have been developed
and tested using Visual Studio Community 2017. They should all work,
unchanged, in Visual Studio Professional 2017 and Visual Studio
Enterprise 2017.
A computer that has a 1.8 GHz or faster processor (dual-core or better
recommended)
2 GB RAM (4 GB RAM recommended, add 512 MB if running in a
virtual machine)
10 GB of available hard disk space after installing Visual Studio
5400 RPM hard-disk drive (SSD recommended)
A video card that supports a 1024 × 768 or higher resolution display
Internet connection to download software or chapter examples
Depending on your Windows configuration, you might require local
Administrator rights to install or configure Visual Studio 2017.
You also need to enable developer mode on your computer to be able to
create and run UWP apps. For details on how to do this, see “Enable Your
Device for Development,” at
https://msdn.microsoft.com/library/windows/apps/dn706236.aspx.
Code samples
Most of the chapters in this book include exercises with which you can
interactively try out new material learned in the main text. You can download all
the sample projects, in both their pre-exercise and post-exercise formats, from
46.
the sample projects,in both their pre-exercise and post-exercise formats, from
the following page:
https://aka.ms/VisCSharp9e/downloads
Note In addition to the code samples, your system should have Visual
Studio 2017 installed. If available, install the latest service packs for
Windows and Visual Studio.
Installing the code samples
Follow these steps to install the code samples on your computer so that you can
use them with the exercises in this book:
1. Unzip the CSharpSBS.zip file that you downloaded from the book’s
website, extracting the files into your Documents folder.
2. If prompted, review the end-user license agreement. If you accept the terms,
select the Accept option and then click Next.
Note If the license agreement doesn’t appear, you can access it from the
same webpage from which you downloaded the CSharpSBS.zip file.
Using the code samples
Each chapter in this book explains when and how to use the code samples for
that chapter. When it’s time to use a code sample, the book will list the
instructions for how to open the files.
47.
Important Many ofthe code samples depend on NuGet packages that are
not included with the code. These packages are downloaded automatically
the first time you build a project. As a result, if you open a project and
examine the code before doing a build, Visual Studio might report a large
number of errors for unresolved references. Building the project will
resolve these references, and the errors should disappear.
For those of you who like to know all the details, here’s a list of the sample
Visual Studio 2017 projects and solutions, grouped by the folders in which you
can find them. In many cases, the exercises provide starter files and completed
versions of the same projects that you can use as a reference. The completed
projects for each chapter are stored in folders with the suffix “- Complete.”
Project/Solution Description
Chapter 1
TextHello This project gets you started. It steps through the
creation of a simple program that displays a text-
based greeting.
Hello This project opens a window that prompts the
user for his or her name and then displays a
greeting.
Chapter 2
PrimitiveDataTypes This project demonstrates how to declare
variables by using each of the primitive types,
how to assign values to these variables, and how
to display their values in a window.
MathsOperators This program introduces the arithmetic operators
(+ – * / %).
Chapter 3
Methods In this project, you’ll reexamine the code in the
MathsOperators project and investigate how it
uses methods to structure the code.
DailyRate This project walks you through writing your own
methods, running the methods, and stepping
through the method calls by using the Visual
48.
through the methodcalls by using the Visual
Studio 2015 debugger.
DailyRate Using
Optional Parameters
This project shows you how to define a method
that takes optional parameters and call the
method by using named arguments.
Chapter 4
Selection This project shows you how to use a cascading if
statement to implement complex logic, such as
comparing the equivalence of two dates.
SwitchStatement This simple program uses a switch statement to
convert characters into their XML
representations.
Chapter 5
WhileStatement This project demonstrates a while statement that
reads the contents of a source file one line at a
time and displays each line in a text box on a
form.
DoStatement This project uses a do statement to convert a
decimal number to its octal representation.
Chapter 6
MathsOperators This project revisits the MathsOperators project
from Chapter 2 and shows how various
unhandled exceptions can make the program fail.
The try and catch keywords then make the
application more robust so that it no longer fails.
Chapter 7
Classes This project covers the basics of defining your
own classes, complete with public constructors,
methods, and private fields. It also shows how to
create class instances by using the new keyword
and how to define static methods and fields.
Chapter 8
Parameters This program investigates the difference between
value parameters and reference parameters. It
demonstrates how to use the ref and out
keywords.
49.
Chapter 9
StructsAndEnums Thisproject defines a struct type to represent a
calendar date.
Chapter 10
Cards This project shows how to use arrays to model
hands of cards in a card game.
Chapter 11
ParamsArray This project demonstrates how to use the params
keyword to create a single method that can
accept any number of int arguments.
Chapter 12
Vehicles This project creates a simple hierarchy of vehicle
classes by using inheritance. It also demonstrates
how to define a virtual method.
ExtensionMethod This project shows how to create an extension
method for the int type, providing a method that
converts an integer value from base 10 to a
different number base.
Chapter 13
Drawing This project implements part of a graphical
drawing package. The project uses interfaces to
define the methods that drawing shapes expose
and implement.
Chapter 14
GarbageCollectionDemo This project shows how to implement exception-
safe disposal of resources by using the Dispose
pattern.
Chapter 15
Drawing Using
Properties
This project extends the application in the
Drawing project developed in Chapter 13 to
encapsulate data in a class by using properties.
AutomaticProperties This project shows how to create automatic
properties for a class and use them to initialize
50.
properties for aclass and use them to initialize
instances of the class.
Chapter 16
Indexers This project uses two indexers: one to look up a
person’s phone number when given a name and
the other to look up a person’s name when given
a phone number.
Chapter 17
BinaryTree This solution shows you how to use generics to
build a type-safe structure that can contain
elements of any type.
BuildTree This project demonstrates how to use generics to
implement a type-safe method that can take
parameters of any type.
Chapter 18
Cards This project updates the code from Chapter 10 to
show how to use collections to model hands of
cards in a card game.
Chapter 19
BinaryTree This project shows you how to implement the
generic IEnumerator<T> interface to create an
enumerator for the generic Tree class.
IteratorBinaryTree This solution uses an iterator to generate an
enumerator for the generic Tree class.
Chapter 20
Delegates This project shows how to decouple a method
from the application logic that invokes it by
using a delegate. The project is then extended to
show how to use an event to alert an object to a
significant occurrence, and how to catch an event
and perform any processing required.
Chapter 21
QueryBinaryTree This project shows how to use LINQ queries to
retrieve data from a binary tree object.
Chapter 22
ComplexNumbers This project defines a new type that models
complex numbers and implements common
51.
complex numbers andimplements common
operators for this type.
Chapter 23
GraphDemo This project generates and displays a complex
graph on a UWP form. It uses a single thread to
perform the calculations.
Parallel GraphDemo This version of the GraphDemo project uses the
Parallel class to abstract out the process of
creating and managing tasks.
GraphDemo With
Cancellation
This project shows how to implement
cancellation to halt tasks in a controlled manner
before they have completed.
ParallelLoop This application provides an example showing
when you should not use the Parallel class to
create and run tasks.
Chapter 24
GraphDemo This is a version of the GraphDemo project from
Chapter 23 that uses the async keyword and the
await operator to perform the calculations that
generate the graph data asynchronously.
PLINQ This project shows some examples of using
PLINQ to query data by using parallel tasks.
CalculatePI This project uses a statistical sampling algorithm
to calculate an approximation for pi. It uses
parallel tasks.
Chapter 25
Customers This project implements a scalable user interface
that can adapt to different device layouts and
form factors. The user interface applies XAML
styling to change the fonts and background
image displayed by the application.
Chapter 26
DataBinding This is a version of the Customers project that
uses data binding to display customer
52.
information retrieved froma data source in the
user interface. It also shows how to implement
the INotifyPropertyChanged interface so that the
user interface can update customer information
and send these changes back to the data source.
ViewModel This version of the Customers project separates
the user interface from the logic that accesses the
data source by implementing the Model-View-
ViewModel pattern.
Cortana This project integrates the Customers app with
Cortana. A user can issue voice commands to
search for customers by name.
Chapter 27
Web Service This solution includes a web application that
provides an ASP.NET Web API web service that
the Customers application uses to retrieve
customer data from a SQL Server database. The
web service uses an entity model created with
the Entity Framework to access the database.
Errata and book support
We’ve made every effort to ensure the accuracy of this book and its companion
content. Any errors that have been reported since this book was published are
listed on our Microsoft Press site at:
https://aka.ms/VisCSharp9e/errata
If you find an error that is not already listed, you can report it to us through
the same page.
If you need additional support, email Microsoft Press Book Support at
mspinput@microsoft.com.
Please note that product support for Microsoft software and hardware is not
offered through the previous addresses. For help with Microsoft software or
hardware, go to https://support.microsoft.com.
53.
Stay in touch
Let’skeep the conversation going! We’re on Twitter:
http://twitter.com/MicrosoftPress
54.
PART I
Introducing MicrosoftVisual C# and
Microsoft Visual Studio 2017
This introductory part of the book covers the essentials of the C# language and
shows you how to get started building applications with Visual Studio 2017.
In Part I, you’ll learn how to create new projects in Visual Studio and how to
declare variables, use operators to create values, call methods, and write many of
the statements you need when implementing C# programs. You’ll also learn how
to handle exceptions and how to use the Visual Studio debugger to step through
your code and spot problems that prevent your applications from working
correctly.
Hän on kaupunginmaalari parhain, katot, seinät hän
kaunistaa. Hän on sälliksi pääsyt jo varhain ja on kulkenut
maailmaa. Hän on tyttöjen piirissä tuttu, ovi hälle ain auki se
on, soi nauru ja luistavi juttu, kun on joukossa Fredrikson.
Hän on herra ja herrojen kanssa hän on tottunut
haastamaan eikä jätkiä vertaisinansa ole sietänyt milloinkaan.
Pyhäpäivin jos mestarin kohtaa kadunvierellä, hieno hän on,
punakukkanen rinnassa hohtaa. — Mihin matkasi, Fredrikson?
Älä kiellä, mä tiedänhän kyllä, tuli tyttö jo vastahain
pyhähamonen parhain yllä — sua varmasti vuotteli vain.
Hymysuin sinä tietäsi jatkat, sysisilmissä tulta nyt on — kuka
laski sun lempesi matkat, sinä tyttöjen Fredrikson!
Mut annahan olla, kun viina sinun sielusi villitsee — miss'
onpi se vilkkuva liina, joka raivosi hillitsee! Minä muistan, kun
viimeisen kerran sinut näin. Kuva mielessä on: isäs haudalla
tarhassa Herran sinä ryyppäsit, Fredrikson.
Sinä itkit ja nauroit vuoroin, sinä kumpuhun pullon löit: "Isä
keskessä enkelikuoroin, minut miksikä pirulle möit? Vähät
siitä! Mä kohtahan lähden, pian kulkuni päättyvä on. Toki vielä
ja juuri sen tähden ota ryyppy nyt, Fredrikson!"
57.
KULJEKSIVA LAULAJA
Kuljeksiva laulaja.
Sinäylpeä linnanneito, sano, muistatko ollenkaan, että
laulaja kerran eksyi luo ikkunas laulamaan.
Oli lempeä, tyyni yöhyt,
suven tuoksuja tulvillaan,
oli taivahan tähti kalpee,
joka tuikahti ikkunaan.
Sinä kuuntelit, ah, sen muistan
alas kaunihin painoit pään.
Minä katselin — sävel sammui
epäsointuhun särkyvään. —
Olen sitten mä sinut nähnyt
seläss' orhisi korskuvan,
olen hiipinyt muurin varjoon
kadun joukon ma suojahan.
Mutta jos sinut tänään kohtaan
kukan rinnasta irroitan
sekä uhmaten sulle heitän
kevätlahjaksi laulajan.
Tämä siunatun kirkas päivä,
sinisiintoinen avaruus,
58.
minut uudeksi onpiluonut,
sävel laulunikin on uus'.
Kuka tiesi sa kerran kuulet
kevätyönä ne säveleet —
varo itseäsi — tuskin lienee
syvät vallisi haudan veet.
Minä tahtoisin, neiti, nähdä alas painuvan kauniin pään, kun
ei lauluni enää sammuis epäsointuhun särkyvään!
Donna Velata.
On liukkaana lattian laatta, valot kirkkahat kynttiläin. Käy
tanssihin, Donna Velata, käy tanssihin seppelpäin!
Sävel kiehtoen kutsuvi, kuule,
mikä kaiho sen kaiusta soi —
älä, ylpeä impeni, luule,
että vastustaa sitä voi!
Sinä taistelet tutkainta vastaan,
hymy kaartavi hienon suun:
ei aatelisherra sois lastaan
näin rahvahan seikkailuun —!
Kuka tuo, joka katsehen heittää —
joko astuvi neidon hän luo?
Puna poskesi, neiti, nyt peittää,
veren lämpimän purppuravuo.
59.
On ryhti kuinkuninkahalla,
niin pystyssä kaunis pää.
Sinä vavahdat katsehen alla,
joka hymysi hälventää.
Sinä unohdat kilpesi kiillon,
jalon syntysi, sukusi puun;
sydän saanut on vamman ja viillon,
ja sä antaut seikkailuun.
On liukkaana lattian laatta,
valot kirkkahat kynttiläin.
Käyt tanssihin, Donna Velata,
käyt tanssihin seppelpäin.
Olet nuori, ja koskena soittaa veri läikkyvä lauleloaan.
Vähät siitä, jos hän, joka voittaa sinun lempesi, renkis on
vaan!
Onni.
Nyt palaa illan tähti korkealla ja suuri, siunattu on
hiljaisuus. Me kaksi, joille tähtivälkkeen alla tän' yönä auennut
on onni uus,
me kädet ristikäämme lasten lailla ja kiittäkäämme pyhää
elämää, kun onnen hetkillänsä autuailla se taipaleemme
taivaan tähdittää.
60.
Ja tarttukaamme hetkeenhäipyväiseen, kuin oljenkorteen
tarttuu hukkuvat — Pian tuijotamme yöhön yksinäiseen ja
tähdet sammuu, sammuu unelmat…
olis vierellä hän…
Yö lämmin ja lempeä heinäkuun, olet armas kuin äityen
syli. Minä unhotun tähties katseluun, kun ne syttyvät
kaupungin yli. Minä kuuntelen laulua leppoisaa, joka
hiljaisuudesta soi, sitä soittavi taivas ja tähdet ja maa, ja mun
syömeni unelmoi:
Olis vierellä hän, jonka kerran näin oven sulkevan jälkeheni
— hän seisoi parvella paljain päin, kun laulaja aamuhun meni
—, olis vieläkin kauniimmat kaiut yön ja kirkkahat kiillot sen ja
välke ois vienompi tähtivyön yli kaupungin hiljaisen!
Pieni kuutamolaulu.
Oli tähtihin kirjoitettu: "Tiet teidän yhtehen käy!" Ja vaikka
ei kirjoitusta kentiesi nyt enää näy, niin sittenkin, sittenkin,
armas, yhä taival on yhteinen, mi alkoi tähtien alla ja
soihtujen ikuisten!
Sinä muistathan: kuudan katsoi ja kurkisti ikkunaan, näki
kaksi se ihmislasta, he kun suuteli toisiaan. Kuu paljon on
61.
lempeä nähnyt, sevanha ja viisas lie — mut tuskin sen
loistossa koskaan on eronnut kahden tie.
Taas hohtavi hopehissa yön taivas ja öinen maa, ikitietänsä
kuuhut kulkee ja tähtöset tuikahtaa. Mitä saanevat tänään
nähdä, kun katsovat ikkunaan? Kaks ihmistä ikäväänsä kun
peittävi toisiltaan —!
Mitä toivoisit —?
Mitä toivoisit, lapseni, itselles, jos satujen haltija astuis sun
luoksesi kerran ja lausuis näin: "Sano tahtosi julki, se
täytetään, tarun aartehet kaikki nyt näytetään, mitä ikinä
mielesi halaa; mikä toive sielussa palaa, kaikk', kaikki on oleva
hetkessä sun!"
"Sano, tahdotko kultaa ja hopeaa tahi suoniisi
kuningasverta, vai tahdotko maailman valloittaa ei olis se ensi
kerta kun naiskädet hennot ja valkeat käy valtikan varteen ja
maailmat sen taipuvat tahdon alle!"
Mitä toivoisit, lapseni kaunis? Et tiedä, et tiedä. En
minäkään. Mut annahan arvailemme! Et tahtone kultaa, et
hopeaa — koi syö sekä ruoste raiskaa —, et maailmaa
tahtone valloittaa — on virran vaahtoa valta, se aallon harjalla
välkähtää ja haihtuvi seuraavalta. Veret suonesi miksi sä
vaihtaisit? sama polttavi kaikkia kaipuu, oli herra tai narri, min
kohtasit, surun alle hän vihdoin vaipuu.
62.
Mut etköhän tahtoisiuudelleen sinä parhaat muistosi elää,
ne, jotka kun istuvi itsekseen kuin kannel sielussa helää?
Minä nään: sinun silmäsi kyyneltyy ja silkkiset ripset kastuu.
— Sano, tiedätkö nyt, mitä toivot sa, kun haltija luoksesi
astuu!
Punahilkka.
Nyt laski venhe rantaan, jo hyppäsit sä santaan, mun oma
armahain. Kun punaliina vilkkuu tuoll' lehtikujan päässä, niin
vanhat piiat ilkkuu, he, joill' on sydän jäässä. Mut ilkkukohot
vain!
Ei meihin pysty pilkka, sä pieni Punahilkka, ei kierot
katsehet. On meillä omat ilomme ja oma valtakunta: on
kirkkaat päivänkilomme ja yömme tuovat unta niin kaunista ja
korkeaa, vain harvoin sitä nähdä saa ja harvat ihmiset.
Ja rannan töyrähällä on muudan koivupuu, min alla
mättähällä — kun kiiltää kalvas kuu ja hopeoipi lahden — voit
meidät nähdä kahden, jos sitä haluat. Näät Punahilkka illoin
kuun sätehiä seuloo ja mulle niistä silloin hän valkokäsin
neuloo ah, sadun kudelmat…
Kerran kesässä.
63.
Kerran kesässä puhkeevain orjantappuran kukka — kerran,
kerran, armahain kukkivi sydän rukka.
Kerran kesässä marjaan käy mansikka purppurahuuli —
eikö mun kultaani vielä näy, vaikka jo ääneni kuuli?
Kaks yksinäistä.
Kaks yksinäistä, jotka hetken sai kuin sattumalta tuta,
minkälainen on sydämien suuri sunnuntai ja kahden onni
yhteensointuvainen…
Kaks yksinäistä, jotka unelmoi,
ett' onni viipyy, kun on onneen usko,
ett' täytten rintain riemunsävel soi,
vaikk' arkeen vaihtuu juhlaillan rusko…
Kaks yksinäistä, joilla muuta ei kuin haavehissaan avain
onnen uksen… Kaks yksinäistä — kuinka heidät vei juur'
yhteen tahto taivaan sallimuksen?
Tornionjoen tuolla puolen.
1.
SÄIVI.
64.
Siell' on vanhavalkoseinä talo vihreen laaksonpohjan
kattilassa akkunoissa aamuruskon palo, kukat valkeet pihan
pihlajassa.
Kaivon vintti tuuliviireinensä
ylös pyrkii poutapilviin asti,
mut ei pääse. Alla räystäittensä
pääskyparvi liikkuu liukkahasti.
Ympärillä uhkeet viljapellot,
metsänreuna kaartaa kauempata —
kilahtavat tarhan karjankellot
säveltänsä kumman kaihoisata.
Mutta etäämmältä, töyrään takaa kuulet meren maininkien
laulun — niin on huomenhohteessakin vakaa sävy säiviläisen
suvitaulun.
* * *
Jänkämaitten keskehen ken raatoi vainiot ja kylvi
leipälaihon, kuka salomaitten kasken kaatoi, kesti ikävän ja
korven kaihon?
Kerrotaan, ett' tuli verityötä
rajan takaa pakoon nuorukainen,
seuras' aurinkoa, tähtivyötä,
tähän tuvan veisti harhalainen.
Täällä yksin kantoi loppuun saakka
murhettansa kolkko korven miesi.
65.
Ei lie kevytollut hällä taakka
eikä lämmin pakopirtin liesi…
Taru tietää, että mökiltänsä
hänet talviaamun valjetessa
löysi erämiesi retkillänsä
hengetönnä tuvan vuotehessa.
Ajastajat siit' on. Joutui ammoin
mökin paikka peittoon tähkäpäiden.
Harvat enää muistanevat kammoin
halmemaiden raivaajata näiden.
Mutta perinnönpä jätti hänkin,
ja se seuraa taloa kuin aave:
vaikk' ois rikkautta enemmänkin,
särkyy täällä herkin sydänhaave.
Milloinkaan et kuullut naurun soivan
vanhan valkeen talon orren alla
etkä nähnyt nuorten karkeloivan —
hiljaa, kuollutta on kaikkialla.
Niin on varhaisvanhaa kehdostansa tämä suruntuttu
sukukunta, ettei uskalla se murheissansa nähdä edes pientä
onnenunta.
2.
METSÄPIRTILTÄ.
66.
On mökki harmaasiellä Sangin sydänmailla, miss' soissa
keltahillat kypsiks käy ja puolat punottavat poimijata vailla ja
polulla ei naapuria näy.
Vain harvoin kirveen iskut kaikuu seutuvilla
ja harvoin siellä paimen huhuilee,
mut luonto luomistuore juhlii soitimilla,
kun korpi kevään virttä humisee.
On tumman tarun koti pieni Metsäpirtti,
miss' Siina-muori elää yksinään.
Mies murhan teki, itsensä hän hirtti,
kun tultiin raudoin häntä etsimään.
Ja tyttäristä toinen nukkuu haudassansa,
on toinen tyhmä neitsyt kaupungin,
mut ainut poika piillen piilojansa
on ammoin mennyt maihin vieraihin.
Näin aivan yksin jääneenä hän postillaansa
kaikk' ankeet ajatukset unhoittaa,
kun pitkät puhteet punoo tunnelmaansa
ja talven taivas luntaan tuiskuaa.
On itkenyt hän kuiviin kaikki kyyneleensä,
nyt odottaapi, milloin hetki lyö,
kun saapuu suuri vieras mökkiseensä
ja ylle muistojensa unhon yö.
Mut korpi siirsi silmiin sinisiinnon kumman ja vanhan
sieluun hiipi hiljaisuus kuin ois se aavistusta yön ja tuonen
tumman tai ehkä ijäisyyden kuulakkuus…
67.
3.
EROJUHLA PYYNYSSÄ.
Suvi multajo loppui, käy huomenna tie päin arkien
askareita. Kai siksi nyt Pyynylle kutsuttu lie kesäpäivien
kumppaneita: siell on Viippa ja Vaara ja posteljuuni,
tinakaulaa pöydällä uhkeeta kuusi ja keskellä pannu on
kiiltävän uusi, se on hohtavan kuuma kuin jouluna uuni.
Juho Pyyny on kievari, krouvari ei, jos kohta hän ryypyn
antaa — kylän miehille riksistä, hellerei, koko tuopinkin
pöytään kantaa. Hän on leikkisä, liukas ja laatuisa miesi, joka
kanna ei kaunaa ja vihaa ei tunne, hymy huulilla aina ja —
meni hän kunne — tulikuumana piippunsa mustunut liesi.
Pyhävaatteiss' on vierahat. Tarina käy.
Soi ylinnä juunin ääni:
"Mitä ihmettä, miksi ei muijaasi näy?
… Älä piiloita ystävääni!"
Hänpä mielevä, metka on naistemme miesi,
joka aina on siisti, ei kiroa koskaan,
pyhäpäivin käy kirkot, on hihhuli, joskaan
sitä arkena harvoin ja harvat vain tiesi.
Juho Pyyny nyt huutavi: "Ystävät hoi, on aika jo kastaa
kaulaa, joka tahtovi, täälläpä kyllä hän voi hyvin hiljaa ja
hiukan laulaa!" Näin on Pyynyssä aljettu ainian kestit;
surujuhla jos lie tahi riemujen päivä, ilo kaikuvi kunnes on
ruskossa häivä. — Nyt on Viippa jo ottanut laulajapestit.
68.
Sanat Viipan onlaulussa muutamat vaan, ei kaikkia ukko
muista: "Tätä lauleli vaarini kiskoessaan pajun kuoria rannan
puista…" Hän on laulaja, laulaja sielultansa; sävel vaikkapa
eksyvi hiukkasen väärään, toki pääsevi nuottinsa matkan hän
määrään. Hikihelmyet hohtavat otsallansa.
Jo on vuorosi, Vaara! Sä lausuhan nyt, mitä aattelet,
kuuntelemme! Monet kerrat jo silmäs on säihkyellyt,
sanatulvaasi salpaa emme. "Sano Suomessa", haastelet,
"Kainuun maas ovat miehiä miehet ja miesten on mieli, sama
heillä on sointuva heimomme kieli, samat metsissä puut,
samat kukkaset haassa…"
Kävi hempeeksi mieli ja hetkisen soi kuin ilmassa kaiho
kumma, oli juunikin vaiti, ja Viippa kun joi, tuli silmihin syttyi
tumma. Mutta kohtapa kaikkovi haikeus sieltä, mihin Pyyny on
pyylevät pullonsa tuonut, soraääntä ei riemuhun tulla hän
suonut: "kuka kyynelin juhlisi!" Pyynyn on kieltä.
69.
*** END OFTHE PROJECT GUTENBERG EBOOK VIRRAN VARRELTA:
RUNOJA ***
Updated editions will replace the previous one—the old editions will
be renamed.
Creating the works from print editions not protected by U.S.
copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.
START: FULL LICENSE
PLEASE READ THISBEFORE YOU DISTRIBUTE OR USE THIS WORK
To protect the Project Gutenberg™ mission of promoting the free
distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.
Section 1. General Terms of Use and
Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.
1.B. “Project Gutenberg” is a registered trademark. It may only be
used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
72.
1.C. The ProjectGutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E. Unless you have removed all references to Project Gutenberg:
1.E.1. The following sentence, with active links to, or other
immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
73.
This eBook isfor the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.
1.E.2. If an individual Project Gutenberg™ electronic work is derived
from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.
1.E.3. If an individual Project Gutenberg™ electronic work is posted
with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.
1.E.4. Do not unlink or detach or remove the full Project
Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.
1.E.5. Do not copy, display, perform, distribute or redistribute this
electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
74.
with active linksor immediate access to the full terms of the Project
Gutenberg™ License.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
1.E.7. Do not charge a fee for access to, viewing, displaying,
performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.
1.E.8. You may charge a reasonable fee for copies of or providing
access to or distributing Project Gutenberg™ electronic works
provided that:
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
75.
about donations tothe Project Gutenberg Literary Archive
Foundation.”
• You provide a full refund of any money paid by a user who
notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.
• You provide, in accordance with paragraph 1.F.3, a full refund of
any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™
electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.
1.F.
1.F.1. Project Gutenberg volunteers and employees expend
considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
76.
damaged disk orother medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.
1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for
the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.
1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you
discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
77.
INCLUDING BUT NOTLIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
1.F.5. Some states do not allow disclaimers of certain implied
warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.
1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,
the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.
Section 2. Information about the Mission
of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.
Volunteers and financial support to provide volunteers with the
assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
78.
remain freely availablefor generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.
Section 3. Information about the Project
Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.
The Foundation’s business office is located at 809 North 1500 West,
Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
79.
small donations ($1to $5,000) are particularly important to
maintaining tax exempt status with the IRS.
The Foundation is committed to complying with the laws regulating
charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.
While we cannot and do not solicit contributions from states where
we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.
International donations are gratefully accepted, but we cannot make
any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Section 5. General Information About
Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
80.
Project Gutenberg™ eBooksare often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
This website includes information about Project Gutenberg™,
including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
81.
Welcome to ourwebsite – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com