Full Download Pro C# 7 With .NET and .NET Core Andrew Troelsen PDF
Full Download Pro C# 7 With .NET and .NET Core Andrew Troelsen PDF
com
https://textbookfull.com/product/pro-c-7-
with-net-and-net-core-andrew-troelsen/
textbookfull
More products digital (pdf, epub, mobi) instant
download maybe you interests ...
https://textbookfull.com/product/pro-c-8-with-net-
core-3-foundational-principles-and-practices-in-programming-
ninth-edition-andrew-troelsen/
https://textbookfull.com/product/pro-c-9-with-net-5-foundational-
principles-and-practices-in-programming-tenth-edition-andrew-
troelsen-phillip-japikse/
https://textbookfull.com/product/pro-c-9-with-net-5-foundational-
principles-and-practices-in-programming-tenth-edition-andrew-
troelsen-phillip-japikse-2/
https://textbookfull.com/product/building-microservices-with-net-
core-2-0-transitioning-monolithic-architectures-using-
microservices-with-net-core-2-0-using-c-7-0-gaurav-aroraa/
C 8 0 and NET Core 3 0 Modern Cross Platform
Development Build applications with C NET Core Entity
Framework Core ASP NET Core and ML NET using Visual
Studio Code 4th Edition Mark J. Price
https://textbookfull.com/product/c-8-0-and-net-core-3-0-modern-
cross-platform-development-build-applications-with-c-net-core-
entity-framework-core-asp-net-core-and-ml-net-using-visual-
studio-code-4th-edition-mark-j-price/
https://textbookfull.com/product/modern-data-access-with-entity-
framework-core-database-programming-techniques-for-net-net-core-
uwp-and-xamarin-with-c-1st-edition-holger-schwichtenberg/
https://textbookfull.com/product/modern-data-access-with-entity-
framework-core-database-programming-techniques-for-net-net-core-
uwp-and-xamarin-with-c-1st-edition-holger-schwichtenberg-2/
https://textbookfull.com/product/pro-asp-net-core-identity-under-
the-hood-with-authentication-and-authorization-in-asp-net-
core-5-and-6-applications-1st-edition-adam-freeman/
https://textbookfull.com/product/c-7-and-net-core-modern-cross-
platform-development-2nd-edition-mark-j-price/
Pro C# 7
With .NET and .NET Core
Eighth Edition
Andrew Troelsen
Philip Japikse
Pro C# 7: With .NET and .NET Core
Andrew Troelsen Philip Japikse
Minneapolis, Minnesota, USA West Chester, Ohio, USA
ISBN-13 (pbk): 978-1-4842-3017-6 ISBN-13 (electronic): 978-1-4842-3018-3
https://doi.org/10.1007/978-1-4842-3018-3
Library of Congress Control Number: 2017958717
Copyright © 2017 by Andrew Troelsen and Philip Japikse
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage
and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or
hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material
contained herein.
Cover image by Freepik (www.freepik.com)
Managing Director: Welmoed Spahr
Editorial Director: Todd Green
Acquisitions Editor: Gwenan Spearing
Development Editor: Laura Berendson
Technical Reviewers: Eric Potter, Lee Brandt, and Sean Whitesell
Coordinating Editor: Mark Powers
Copy Editor: Kim Wimpsett
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
[email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC
and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc).
SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected], or visit www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions
and licenses are also available for most titles. For more information, reference our Print and eBook Bulk
Sales web page at www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484230176. For more
detailed information, please visit www.apress.com/source-code.
Printed on acid-free paper
Contents at a Glance
■
■Part I: Introducing C# and the .NET Platform������������������������������������� 1
■
■Chapter 1: The Philosophy of .NET������������������������������������������������������������������������� 3
■
■Chapter 2: Building C# Applications�������������������������������������������������������������������� 35
■
■Part II: Core C# Programing�������������������������������������������������������������� 53
■
■Chapter 3: Core C# Programming Constructs, Part I������������������������������������������� 55
■
■Chapter 4: Core C# Programming Constructs, Part II���������������������������������������� 111
■
■Part III: Object-Oriented Programming with C#������������������������������ 159
■
■Chapter 5: Understanding Encapsulation���������������������������������������������������������� 161
■
■Chapter 6: Understanding Inheritance and Polymorphism�������������������������������� 213
■
■Chapter 7: Understanding Structured Exception Handling�������������������������������� 255
■
■Chapter 8: Working with Interfaces������������������������������������������������������������������� 283
■
■Part IV: Advanced C# Programming����������������������������������������������� 323
■
■Chapter 9: Collections and Generics������������������������������������������������������������������ 325
■
■Chapter 10: Delegates, Events, and Lambda Expressions��������������������������������� 365
■
■Chapter 11: Advanced C# Language Features��������������������������������������������������� 407
■
■Chapter 12: LINQ to Objects������������������������������������������������������������������������������� 445
■
■Chapter 13: Understanding Object Lifetime������������������������������������������������������� 479
v
■ Contents at a Glance
■
■Part V: Programming with .NET Assemblies����������������������������������� 507
■
■Chapter 14: Building and Configuring Class Libraries��������������������������������������� 509
■■Chapter 15: Type Reflection, Late Binding, and Attribute-Based Programming���� 561
■
■Chapter 16: Dynamic Types and the Dynamic Language Runtime�������������������� 609
■
■Chapter 17: Processes, AppDomains, and Object Contexts������������������������������� 631
■
■Chapter 18: Understanding CIL and the Role of Dynamic Assemblies��������������� 657
■
■Part VI: Introducing the .NET Base Class Libraries������������������������� 699
■
■Chapter 19: Multithreaded, Parallel, and Async Programming������������������������� 701
■
■Chapter 20: File I/O and Object Serialization���������������������������������������������������� 755
■
■Chapter 21: Data Access with ADO.NET������������������������������������������������������������� 803
■
■Chapter 22: Introducing Entity Framework 6���������������������������������������������������� 857
■
■Chapter 23: Introducing Windows Communication Foundation������������������������ 907
■
■Part VII: Windows Presentation Foundation����������������������������������� 963
■
■Chapter 24: Introducing Windows Presentation Foundation and XAML������������� 965
■
■Chapter 25: WPF Controls, Layouts, Events, and Data Binding������������������������ 1003
■
■Chapter 26: WPF Graphics Rendering Services����������������������������������������������� 1061
■
■Chapter 27: WPF Resources, Animations, Styles, and Templates�������������������� 1095
■
■Chapter 28: WPF Notifications, Validations, Commands, and MVVM��������������� 1137
■
■Part VIII: ASP.NET.������������������������������������������������������������������������� 1177
■
■Chapter 29: Introducing ASP.NET MVC������������������������������������������������������������� 1179
■
■Chapter 30: Introducing ASP.NET Web API������������������������������������������������������� 1223
■
■Part IX: .NET CORE������������������������������������������������������������������������ 1243
■
■Chapter 31: The Philosophy of .NET Core�������������������������������������������������������� 1245
■
■Chapter 32: Introducing Entity Framework Core��������������������������������������������� 1255
■
■Chapter 33: Introducing ASP.NET Core Web Applications�������������������������������� 1279
■
■Chapter 34: Introducing ASP.NET Core Service Applications��������������������������� 1329
Index������������������������������������������������������������������������������������������������������������������� 1353
vi
Contents
■
■Part I: Introducing C# and the .NET Platform������������������������������������� 1
■
■Chapter 1: The Philosophy of .NET������������������������������������������������������������������������� 3
An Initial Look at the .NET Platform��������������������������������������������������������������������������������� 3
Some Key Benefits of the .NET Platform������������������������������������������������������������������������������������������������ 4
Introducing the Building Blocks of the .NET Platform (the CLR, CTS, and CLS)���������������� 4
The Role of the Base Class Libraries������������������������������������������������������������������������������������������������������ 5
What C# Brings to the Table������������������������������������������������������������������������������������������������������������������� 5
Managed vs. Unmanaged Code�������������������������������������������������������������������������������������������������������������� 8
vii
■ Contents
Summary������������������������������������������������������������������������������������������������������������������������ 33
■
■Chapter 2: Building C# Applications�������������������������������������������������������������������� 35
Building .NET Applications on Windows������������������������������������������������������������������������� 35
Installing Visual Studio 2017���������������������������������������������������������������������������������������������������������������� 36
Taking Visual Studio 2017 for a Test-Drive������������������������������������������������������������������������������������������� 38
Visual Studio 2017 Professional����������������������������������������������������������������������������������������������������������� 50
Visual Studio 2017 Enterprise�������������������������������������������������������������������������������������������������������������� 50
The .NET Framework Documentation System�������������������������������������������������������������������������������������� 50
viii
■ Contents
■
■Part II: Core C# Programing�������������������������������������������������������������� 53
■
■Chapter 3: Core C# Programming Constructs, Part I������������������������������������������� 55
The Anatomy of a Simple C# Program���������������������������������������������������������������������������� 55
Variations on the Main( ) Method���������������������������������������������������������������������������������������������������������� 57
Specifying an Application Error Code��������������������������������������������������������������������������������������������������� 58
Processing Command-Line Arguments������������������������������������������������������������������������������������������������ 59
Specifying Command-Line Arguments with Visual Studio�������������������������������������������������������������������� 61
ix
■ Contents
C# Iteration Constructs��������������������������������������������������������������������������������������������������� 98
The for Loop������������������������������������������������������������������������������������������������������������������������������������������ 98
The foreach Loop���������������������������������������������������������������������������������������������������������������������������������� 99
Use of Implicit Typing Within foreach Constructs��������������������������������������������������������������������������������� 99
The while and do/while Looping Constructs�������������������������������������������������������������������������������������� 100
Summary���������������������������������������������������������������������������������������������������������������������� 109
■
■Chapter 4: Core C# Programming Constructs, Part II���������������������������������������� 111
Understanding C# Arrays���������������������������������������������������������������������������������������������� 111
C# Array Initialization Syntax�������������������������������������������������������������������������������������������������������������� 112
Implicitly Typed Local Arrays�������������������������������������������������������������������������������������������������������������� 113
x
■ Contents
xi
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 158
■
■Part III: Object-Oriented Programming with C#������������������������������ 159
■
■Chapter 5: Understanding Encapsulation���������������������������������������������������������� 161
Introducing the C# Class Type�������������������������������������������������������������������������������������� 161
Allocating Objects with the new Keyword������������������������������������������������������������������������������������������ 164
xii
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 212
■
■Chapter 6: Understanding Inheritance and Polymorphism�������������������������������� 213
The Basic Mechanics of Inheritance���������������������������������������������������������������������������� 213
Specifying the Parent Class of an Existing Class�������������������������������������������������������������������������������� 214
Regarding Multiple Base Classes������������������������������������������������������������������������������������������������������� 216
The sealed Keyword��������������������������������������������������������������������������������������������������������������������������� 216
xiii
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 254
■
■Chapter 7: Understanding Structured Exception Handling�������������������������������� 255
Ode to Errors, Bugs, and Exceptions���������������������������������������������������������������������������� 255
The Role of .NET Exception Handling��������������������������������������������������������������������������� 256
The Building Blocks of .NET Exception Handling�������������������������������������������������������������������������������� 257
The System.Exception Base Class������������������������������������������������������������������������������������������������������ 257
xiv
■ Contents
xv
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 321
■
■Part IV: Advanced C# Programming����������������������������������������������� 323
■
■Chapter 9: Collections and Generics������������������������������������������������������������������ 325
The Motivation for Collection Classes�������������������������������������������������������������������������� 325
The System.Collections Namespace�������������������������������������������������������������������������������������������������� 327
A Survey of System.Collections.Specialized Namespace������������������������������������������������������������������� 329
xvi
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 363
■
■Chapter 10: Delegates, Events, and Lambda Expressions��������������������������������� 365
Understanding the .NET Delegate Type������������������������������������������������������������������������ 365
Defining a Delegate Type in C#����������������������������������������������������������������������������������������������������������� 366
The System.MulticastDelegate and System.Delegate Base Classes�������������������������������������������������� 369
xvii
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 406
■
■Chapter 11: Advanced C# Language Features��������������������������������������������������� 407
Understanding Indexer Methods���������������������������������������������������������������������������������� 407
Indexing Data Using String Values������������������������������������������������������������������������������������������������������ 409
Overloading Indexer Methods������������������������������������������������������������������������������������������������������������� 411
Indexers with Multiple Dimensions���������������������������������������������������������������������������������������������������� 411
Indexer Definitions on Interface Types������������������������������������������������������������������������������������������������ 412
xviii
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 444
■
■Chapter 12: LINQ to Objects������������������������������������������������������������������������������� 445
LINQ-Specific Programming Constructs����������������������������������������������������������������������� 445
Implicit Typing of Local Variables������������������������������������������������������������������������������������������������������� 446
Object and Collection Initialization Syntax����������������������������������������������������������������������������������������� 446
xix
■ Contents
xx
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 478
■
■Chapter 13: Understanding Object Lifetime������������������������������������������������������� 479
Classes, Objects, and References�������������������������������������������������������������������������������� 479
The Basics of Object Lifetime��������������������������������������������������������������������������������������� 480
The CIL of new������������������������������������������������������������������������������������������������������������������������������������ 481
Setting Object References to null������������������������������������������������������������������������������������������������������� 483
Summary���������������������������������������������������������������������������������������������������������������������� 505
xxi
■ Contents
■
■Part V: Programming with .NET Assemblies����������������������������������� 507
■
■Chapter 14: Building and Configuring Class Libraries��������������������������������������� 509
Defining Custom Namespaces������������������������������������������������������������������������������������� 509
Resolving Name Clashes with Fully Qualified Names������������������������������������������������������������������������ 511
Resolving Name Clashes with Aliases������������������������������������������������������������������������������������������������ 513
Creating Nested Namespaces������������������������������������������������������������������������������������������������������������ 514
The Default Namespace of Visual Studio�������������������������������������������������������������������������������������������� 515
xxii
■ Contents
xxiii
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 607
■
■Chapter 16: Dynamic Types and the Dynamic Language Runtime�������������������� 609
The Role of the C# dynamic Keyword��������������������������������������������������������������������������� 609
Calling Members on Dynamically Declared Data�������������������������������������������������������������������������������� 611
The Role of the Microsoft.CSharp.dll Assembly���������������������������������������������������������������������������������� 612
The Scope of the dynamic Keyword��������������������������������������������������������������������������������������������������� 613
Limitations of the dynamic Keyword�������������������������������������������������������������������������������������������������� 614
Practical Uses of the dynamic Keyword��������������������������������������������������������������������������������������������� 614
Summary���������������������������������������������������������������������������������������������������������������������� 629
xxv
■ Contents
■
■Chapter 17: Processes, AppDomains, and Object Contexts������������������������������� 631
The Role of a Windows Process����������������������������������������������������������������������������������� 631
The Role of Threads���������������������������������������������������������������������������������������������������������������������������� 632
xxvi
■ Contents
.NET Base Class Library, C#, and CIL Data Type Mappings������������������������������������������� 675
Defining Type Members in CIL�������������������������������������������������������������������������������������� 675
Defining Field Data in CIL������������������������������������������������������������������������������������������������������������������� 676
Defining Type Constructors in CIL������������������������������������������������������������������������������������������������������� 676
Defining Properties in CIL������������������������������������������������������������������������������������������������������������������� 677
Defining Member Parameters������������������������������������������������������������������������������������������������������������� 678
xxvii
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 698
■
■Part VI: Introducing the .NET Base Class Libraries������������������������� 699
■
■Chapter 19: Multithreaded, Parallel, and Async Programming������������������������� 701
The Process/AppDomain/Context/Thread Relationship������������������������������������������������ 701
The Problem of Concurrency�������������������������������������������������������������������������������������������������������������� 702
The Role of Thread Synchronization��������������������������������������������������������������������������������������������������� 703
xxviii
■ Contents
xxix
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 754
■
■Chapter 20: File I/O and Object Serialization���������������������������������������������������� 755
Exploring the System.IO Namespace��������������������������������������������������������������������������� 755
The Directory(Info) and File(Info) Types������������������������������������������������������������������������ 756
The Abstract FileSystemInfo Base Class�������������������������������������������������������������������������������������������� 757
Summary���������������������������������������������������������������������������������������������������������������������� 801
■
■Chapter 21: Data Access with ADO.NET������������������������������������������������������������� 803
A High-Level Definition of ADO.NET������������������������������������������������������������������������������ 803
The Three Faces of ADO.NET�������������������������������������������������������������������������������������������������������������� 804
xxxi
Another random document with
no related content on Scribd:
379. Mr. Maclaurin having noticed that the Author of Nature has
made it impossible for us to have any communication, from this
earth, with the other great bodies of the universe, in our present
state; and after remarking on some phænomena in the planetary
system, makes the following just reflections, which correspond with
those expressed by Dr. Rittenhouse, in the concluding pages of his
Oration:—“From hence, as well as from the state of the moral world
and many other considerations, we are induced to believe, that our
present state would be very imperfect without a subsequent one;
wherein our views of nature, and of its great Author, may be more
clear and satisfactory. It does not appear to be suitable to the
wisdom that shines throughout all nature, to suppose that we should
see so far, and have our curiosity so much raised concerning the
works of God, only to be disappointed in the end. As man is
undoubtedly the chief being upon this globe, and this globe may be
no less considerable, in the most valuable respects, than any other
in the solar system, and this system, for ought we know, not inferior
to any other in the universal system; so, if we should suppose man
to perish, without ever arriving at a more complete knowledge of
nature, than the very imperfect one he attains in his present state; by
analogy, or parity of reason, we might conclude, that the like desires
would be frustrated in the inhabitants of all the other planets and
systems; and that the beautiful scheme of nature would never be
unfolded, but in an exceedingly imperfect manner, to any of them.
This, therefore, naturally leads us to consider our present state as
only the dawn or beginning of our existence, and as a state of
preparation or probation for farther advancement: which appears to
have been the opinion of the most judicious philosophers of old. And
whoever attentively considers the constitution of human nature,
particularly the desires and passions of men, which appear greatly
superior to their present objects, will easily be persuaded that man
was designed for higher views than of this life. Surely, it is in His
power to grant us a far greater improvement of the faculties we
already possess, or even to endow us with new faculties, of which, at
this time, we have no idea, for penetrating farther into the scheme of
nature, and approaching nearer to Himself, the First and Supreme
Cause.”
The striking coincidence of the foregoing sentiments, with those
expressed by Dr. Rittenhouse; in addition to the sublimity of the
conceptions; the cogency of the argument; and the weight of the
concurring opinions of two so great astronomers and
mathematicians, on a subject of such high importance to mankind;
all plead an apology for the length of this extract, from Maclaurin’s
Account of Sir Isaac Newton’s Philosophical Discoveries.
AN ORATION,
DELIVERED FEBRUARY 24, 1775,
BEFORE
THE AMERICAN PHILOSOPHICAL SOCIETY,
HELD AT PHILADELPHIA,
FOR PROMOTING USEFUL KNOWLEDGE.
BY DAVID RITTENHOUSE, A. M.
MEMBER OF THE SAID SOCIETY.
(INSCRIBED)
Gentlemen,
The Egyptians too, we are told, had observations of the stars for
one thousand five hundred years before the Christian era. What they
were, is not known; but probably the astronomy of those ages
consisted in little more than remarks on the rising and setting of the
fixed stars, as they were found to correspond with the seasons of the
year;[A4] and, perhaps, forming them into constellations. That this was
done early, appears from the book of Job, which has by some been
attributed to Moses, who is said to have been learned in the
sciences of Egypt.[A5] “Canst thou bind the sweet influences of
Pleiades, or loose the bands of Orion? Canst thou bring forth
Mazzaroth in his season, or canst thou guide Arcturus with his
sons?” Perhaps too, some account might be kept of eclipses of the
sun and moon, as they happened, without pretending to predict them
for the future. These eclipses are thought by some to have been
foretold by the Jewish prophets in a supernatural way.
Next follows the noble Tycho,[A10] who with great labour and
perseverance, brought the art of observing the heavens to a degree
of accuracy unknown to the ancients; though in theory he mangled
the beautiful system of Copernicus. The whimsical Kepler, too,
(whose fondness for analogies frequently led him astray, yet
sometimes happily conducted him to important truths) did notable
services to astronomy: and from his time down to the present, so
many great men have appeared amongst the several nations of
Europe, rivalling each other in the improvement of astronomy, that I
should trespass on your patience were I to enumerate them. I shall
therefore proceed to what I proposed in the second place, and take
notice of some of the most important discoveries in this science.
The first discovery then, which paved the way for others more
curious, seems to have been the circular figure of the earth, inferred
from observing the meridian altitudes of the sun and stars to be
different in distant places. This conclusion would probably not be
immediately drawn, but the appearance accounted for, by the
rectilinear motion of the traveller; and then a change in the apparent
situations of the heavenly bodies would only argue their nearness to
the earth: and thus would the observation contribute to establish
error, instead of promoting truth, which has been the misfortune of
many an experiment. It would require some skill in geometry, as well
as practice in observing angles, to demonstrate the spherical figure
of the earth from such observations.[A12]
But this difficulty being surmounted, and the true figure of the earth
discovered, a free space would now be granted for the sun, moon,
and stars to perform their diurnal motions on all sides of it; unless
perhaps at its extremities to the north and south; where something
would be thought necessary to serve as an axis for the heavens to
revolve on. This Mr. Crantz in his very entertaining history of
Greenland informs us, is agreeable to the philosophy of that country,
with this difference perhaps, that the high latitude of the Greenlander
makes him conclude one pole only, necessary: He therefore
supposes a vast mountain situate in the utmost extremity of
Greenland, whose pointed apex supports the canopy of heaven, and
whereon it revolves with but little friction.
For two or three centuries before and after the beginning of the
Christian era, astronomy appears to have been held in considerable
repute; yet very few discoveries of any consequence were made,
during that period and many ages following.
The ancients were not wanting in their endeavours to find out the
true dimensions of the planetary system. They invented several very
ingenious methods for the purpose; but none of them were at all
equal, in point of accuracy, to the difficulty of the problem. They were
therefore obliged to rest satisfied with supposing the heavenly
bodies much nearer to the earth than in fact they are, and
consequently much less in proportion to it. Add to this, that having
found the earth honoured with an attendant, while they could
discover none belonging to any of the other planets, they supposed it
of far greater importance in the Solar System than it appears to us to
be: And the more praise is due to those few, who nevertheless
conceived rightly of its relation to the whole.
Amongst the fixed stars too, Galileo pursued his enquiries. The
Milky-Way, which had so greatly puzzled the ancient Philosophers,
and which Aristotle imagined to be vapours risen to an extraordinary
height, he found to consist of an innumerable multitude of small
stars; whose light appears indistinct and confounded together to the
naked eye. And in every part of the heavens, his telescope shewed
him abundance of stars, not visible without it. In short, with such
unabated ardour did this great man range through the fields of
Astronomy, that he seemed to leave nothing for others to glean after
him.
As the apparent motion of the fixed stars, arising from this cause,
was observed to complete the intire circle of its changes in the space
of a year, it was for some time supposed to arise from an annual
parallax, notwithstanding its inconsistency in other respects with
such a supposition. But this obstacle being removed, there followed
the discovery of another apparent motion in the heavens, arising
from the nutation of the earth’s axis; the period whereof is about
nineteen years. Had it not been so very different from the period of
the former, the causes of both must have been almost inexplicable.
This latter discovery is an instance of the superior advantages of
accurate observation: For it was well known that such a nutation
must take place from the principles of the Newtonian Philosophy; yet
a celebrated astronomer had concluded from hypothetical reasoning,
that its quantity must be perfectly insensible.
The way being cleared thus far, Dr. Bradley assures us, from his
most accurate observations, that the annual parallax cannot exceed
two seconds, he thinks not one; and we have the best reason to
confide in his judgment and accuracy. From hence then we draw this
amazing conclusion; that the diameter of the earth’s orb bears no
greater proportion to the distance of the stars which Bradley
observed, than one second does to the radius; which is less than as
one to 200,000. Prodigiously great as the distance of the fixed stars
from our sun appears to be, and probably their distances from each
other are no less, the Newtonian Philosophy will furnish us with a
reason for it: That the several systems may be sufficiently removed
from each other’s attraction, which we are very certain must require
an immense distance; especially if we consider that the cometic part,
of our system at least, appears to be the most considerable though
so little known to us. The dimensions of the several parts of the
planetary system, had been determined near the truth by the
astronomers of the last age, from the parallax of Mars. But from that
rare phenomenon the transit of Venus over the sun’s disk, which has
twice happened within a few years past, the sun’s parallax is now
known beyond dispute to be 8 seconds and an half, nearly; and
consequently, the sun’s distance almost 12,000 diameters of the
earth.
But how does Astronomy change the scene!—Take the miser from
the earth, if it be possible to disengage him; he whose nightly rest
has been long broken by the loss of a single foot of it, useless
perhaps to him; and remove him to the planet Mars, one of the least
distant from us: Persuade the ambitious monarch to accompany him,
who has sacrificed the lives of thousands of his subjects to an
imaginary property in certain small portions of the earth; and now
point it out to them, with all its kingdoms and wealth, a glittering star
“close by the moon,” the latter scarce visible and the former less
bright than our Evening Star:—Would they not turn away their
disgusted sight from it, as not thinking it worth their smallest
attention, and look for consolation in the gloomy regions of Mars?[A32]