C Unleashed 1st Edition Joseph Mayo 2024 Scribd Download
C Unleashed 1st Edition Joseph Mayo 2024 Scribd Download
https://ebookgate.com/product/mayo-clinic-cardiology-concise-
textbook-4th-edition-joseph-g-murphy/
ebookgate.com
https://ebookgate.com/product/mayo-clinic-gastroenterology-and-
hepatology-board-review-4ed-edition-stephen-c-hauser/
ebookgate.com
https://ebookgate.com/product/j2ee-unleashed-1st-edition-mark-
ashnault/
ebookgate.com
https://ebookgate.com/product/the-apache-2nd-edition-joseph-c-
jastrzembski/
ebookgate.com
Interest Groups Unleashed 1st Edition Paul S. Herrnson
https://ebookgate.com/product/interest-groups-unleashed-1st-edition-
paul-s-herrnson/
ebookgate.com
https://ebookgate.com/product/mayo-clinic-body-mri-case-review-1st-
edition-glockner/
ebookgate.com
https://ebookgate.com/product/microsoft-expression-
blend-4-unleashed-1st-edition-brennon-williams/
ebookgate.com
https://ebookgate.com/product/microsoft-sharepoint-2007-development-
unleashed-1st-edition-kevin-hoffman/
ebookgate.com
https://ebookgate.com/product/visual-basic-2010-unleashed-1st-edition-
alessandro-del-sole/
ebookgate.com
C#
Joseph Mayo
Unleashed
PUBLISHER
C# Unleashed Paul Boger
Copyright © 2002 by Sams Publishing
EXECUTIVE EDITOR
All rights reserved. No part of this book shall be reproduced, stored in a
Shelley Kronzek
retrieval system, or transmitted by any means, electronic, mechanical, photo-
copying, recording, or otherwise, without written permission from the publish- DEVELOPMENT EDITOR
er. No patent liability is assumed with respect to the use of the information Susan Hobbs
contained herein. Although every precaution has been taken in the preparation
MANAGING EDITOR
of this book, the publisher and author assume no responsibility for errors or
Charlotte Clapp
omissions. Nor is any liability assumed for damages resulting from the use of
the information contained herein. PROJECT EDITORS
International Standard Book Number: 0-672-32122-x Elizabeth Finney
Leah Kirkpatrick
Library of Congress Catalog Card Number: 00-111066
COPY EDITOR
Printed in the United States of America
Maryann Steinhart
First Printing: November 2001
INDEXER
04 03 02 01 4 3 2 1 D&G Limited, LLC
Trademarks PROOFREADER
D&G Limited, LLC
All terms mentioned in this book that are known to be trademarks or service
marks have been appropriately capitalized. Sams Publishing cannot attest to TECHNICAL EDITORS
the accuracy of this information. Use of a term in this book should not be Kevin Burton
regarded as affecting the validity of any trademark or service mark. Bill Craun
TEAM COORDINATOR
Warning and Disclaimer Pamalee Nelson
Every effort has been made to make this book as complete and as accurate as
possible, but no warranty or fitness is implied. The information provided is on MEDIA DEVELOPER
an “as is” basis. The author and the publisher shall have neither liability nor Dan Scherf
responsibility to any person or entity with respect to any loss or damages aris- INTERIOR DESIGNER
ing from the information contained in this book or from the use of programs Gary Adair
accompanying it.
COVER DESIGNER
Aren Howell
PAGE LAYOUT
D&G Limited, LLC
Contents at a Glance
Introduction 1
PART I C# Basics 9
1 The C# Environment 11
2 Getting Started with C# 19
3 Writing C# Expressions 47
4 Using Statements and Loops to Control Program Flow 69
5 Debugging and Pre-Processing 91
Index 775
Contents
Introduction 1
Part I C# Basics 9
1 The C# Environment 11
The Common Language Infrastructure (CLI) ......................................12
Standardization ....................................................................................15
The .NET Architecture ........................................................................16
Common Language Runtime (CLR) ..............................................16
Libraries ..........................................................................................16
Languages ........................................................................................17
Where C# Fits In ..................................................................................17
Summary ..............................................................................................17
3 Writing C# Expressions 47
Unary Operators ....................................................................................48
The Plus Operator ............................................................................48
The Minus Operator ........................................................................49
The Increment Operator ..................................................................49
The Decrement Operator ................................................................50
The Logical Complement Operator ................................................50
The Bitwise Complement Operator ................................................50
Binary Operators ..................................................................................51
Arithmetic Operators ......................................................................51
Relational Operators ........................................................................53
Logical Operators ............................................................................55
Assignment Operators ....................................................................58
The Ternary Operator ..........................................................................59
Other Operators ....................................................................................60
The is Operator ..............................................................................60
The as Operator ..............................................................................60
The sizeof() Operator ..................................................................60
The typeof() Operator ..................................................................60
The checked() Operator ..................................................................61
The unchecked() Operator ..............................................................61
Enumeration Expressions ....................................................................61
Array Expressions ................................................................................63
Statements ............................................................................................65
Blocks ..................................................................................................65
Labels ....................................................................................................66
Declarations ..........................................................................................66
Operator Precedence and Associativity ................................................66
Summary ..............................................................................................68
Polymorphism ....................................................................................200
Implementing Polymorphism ........................................................201
Hiding Again ................................................................................206
Most-Derived Implementations ....................................................210
Polymorphic Properties ................................................................213
Polymorphic Indexers ....................................................................215
Summary ............................................................................................217
18 XML 407
Writing ................................................................................................408
Reading ..............................................................................................411
Summary ............................................................................................416
21 Remoting 459
Basic Remoting ..................................................................................460
Remoting Server ............................................................................461
Remoting Client ............................................................................463
Remoting Setup ............................................................................465
Proxys ................................................................................................471
Channels ..............................................................................................475
Lifetime Management ........................................................................478
Summary ............................................................................................481
26 C# Collections 545
Pre-Existing Collections ....................................................................546
The ArrayList Collection ............................................................546
The BitArray Collection ..............................................................547
The Hashtable Collection ............................................................549
The Queue Collection ....................................................................549
The SortedList Collection ..........................................................550
The Stack Collection ....................................................................551
Collection Interfaces ..........................................................................552
Creating a Collection ..........................................................................553
A List Collection ..........................................................................553
Using the SiteList Collection ......................................................563
Summary ............................................................................................565
27 Attributes 567
Using Attributes ..................................................................................568
Using a Single Attribute ................................................................568
Using Multiple Attributes ..............................................................569
Using Attribute Parameters ................................................................570
Positional Parameters ....................................................................571
Named Parameters ........................................................................571
Using Attribute Targets ......................................................................572
Creating Your Own Attributes ............................................................574
The AttributeUsage Attribute ......................................................574
Getting Attributes from a Class ..........................................................578
Summary ............................................................................................579
28 Reflection 581
Discovering Program Information ......................................................582
Dynamically Activating Code ............................................................588
Reflection.Emit ................................................................................590
Summary ............................................................................................594
Index 775
About the Author
Joe Mayo is a pioneer within the C# community. Joe created the C# Station Web site
shortly after this new language was introduced. His very popular C# Tutorials are
accessed by Web developers and Web sites throughout the world. Joe is a seasoned
developer with more than 15 years of robust experience. Over the years, he has pro-
grammed in a variety of languages including assembler, C, C++, VBA, and Forte 4GL.
His database experience encompasses Paradox, Dbase III, MS Access, and Oracle.
Frameworks include MFC and Motif. He has programmed several operating systems
including VAX VMS, RSX-11, UNIX, and several versions of MS-DOS and MS
Windows. He has developed applications in standalone mode for desktops, client-server
on LANs, and n-tier applications on LANs and WANs. Joe opened a Web site titled C#
Station in late June 2000. He is currently a software engineer for Quest
Communications.
Dedication
To my beautiful wife, Maytinee
—Joe Mayo
Acknowledgments
Although my name appears on the cover of this book, work of such magnitude could
never have occurred without the valuable contributions of many people. To the people at
Sams Publishing, Microsoft, and friends and family I am eternally grateful.
I’d first like to thank Shelley Kronzek, Executive Editor, for finding me and offering this
wonderful opportunity. Her leadership is inspiring. Susan Hobbs, Development Editor,
was totally awesome, keeping me on focus and organized. Maryann Steinhart, Copy
Editor, made my writing look great. Other people at Sams Publishing I’d like to recog-
nize include Katie Robinson, Leah Kirkpatrick, Elizabeth Finney, Pamalee Nelson, and
Laurie McGuire. Thanks also to all the editors, indexers, printers, production, and other
people at Sams who have contributed to this book.
Special thanks goes to Kevin Burton and Bill Craun, technical editors. Their technical
expertise and advice was absolutely top-notch. They provided detailed pointers, and their
perspectives made a significant difference. Thanks to Keith Olsen, Charles Tonklinson,
Cedric, and Christoph Wille for reviewing my early work.
Thanks to all the people at Microsoft who set up author seminars and training. They are
transforming the way we do computing and leading the industry in a move of historic
proportions—an initiative deserving of much praise. Special thanks to Eric Gunnerson
for taking time out of his extremely busy schedule to review my chapters.
This first book is a significant milestone in my life. As such, I must recognize those peo-
ple who contributed to my success. In many ways, they define who I am.
Thanks to family members: Maytinee Mayo, Joseph A. Mayo Jr., Jennifer A. Mayo,
Kamonchon Ahantric, Lacee and June Mayo, Bob Mayo, Margina Mayo, Richard Mayo,
Gary Mayo, Mike Mayo, Tony Gravagno, Tim and Kirby Hoffman, Richard and Barbara
Bickerstaff, Bobbie Jo Burns, David Burns, Mistie Lea Bickerstaff, Cecil Sr. and
Margaret Sloan, Cecil Jr. and Jean Sloan, Lou and Rose Weiner, Mary and Ron Monette,
Jack Freeman Sr., and Bill Freeman.
Thanks to friends and professional associates: Evelyn Black, Harry G. Hall, Arthur E.
Richardson, Carl S. Markussen, Judson Meyer, Hoover McCoy, Bill Morris, Gary Meyer,
Tim Leuers, Angela Dees-Prebula, Bob Jangraw, Jean-Paul Massart, Jeff and Stephanie
Manners, Eddie Alicea, Gary and Gloria Lefebvre, Bob Turbyfill, and Dick Van
Bennekom, Barry Patterson, Otis Solomon, and Brian Allen.
Tell Us What You Think!
As the reader of this book, you are our most important critic and commentator. We value
your opinion and want to know what we’re doing right, what we could do better, what
areas you’d like to see us publish in, and any other words of wisdom you’re willing to
pass our way.
As an Executive Editor for Sams, I welcome your comments. You can e-mail or
write me directly to let me know what you did or didn’t like about this book—as well as
what we can do to make our books stronger.
Please note that I cannot help you with technical problems related to the topic of this
book, and that due to the high volume of mail I receive, I might not be able to reply to
every message.
When you write, please be sure to include this book’s title and author as well as your
name and phone or fax number. I will carefully review your comments and share them
with the author and editors who worked on the book.
Email: feedback@samspublishing.com
Mail: Mark Taber
Executive Editor
Sams Publishing
800 East 96th Street
Indianapolis, IN 46240 USA
Introduction
Welcome to C# Unleashed, a programmer’s guide and reference to the C# (pronounced
“see sharp”) programming language. C# is a brand-new object-oriented programming
(OOP) language that emphasizes a component-based approach to software development.
While component-based programming has been with us, in one form or another, for a
few years now, the vision of what C# enables promises to take us to the next level in
software development. This is the new paradigm shift toward XML Web Services—the
view of software as a service, disconnected, stateless, and conforming to international
open standards.
Software as a service is the vision of the next generation of computing systems. For
example, C# is well suited for building Web services, reusable components on the
Internet that conform to open standards. Software development is no longer constrained
to the monolithic architectures we have been developing over the last several years. Web
services enable applications to use distributed services over the Web, which simplify
development and promote a greater scale of software reuse. C# is a major player in the
Web services arena, promoting the vision of software as a service.
This book not only teaches the C# language itself, but its goal is to show how C# could
be used to develop software as a service. Looking at the evolution of software, it’s evi-
dent how we’ve reached this point in time. For many years, programs were written as
monolithic applications with a single purpose. Through research and experience, we
realized the benefits of modularization, which eventually led to object-oriented methods.
This gave us large-scale re-use and maintainability. Client/server and networking tech-
nology evolved naturally as collaboration and communication became business require-
ments. Enter the Internet and Web technology, providing distributed, stateless, and secure
software technologies, including applets and other Web page objects. The next evolution-
ary step is where C# fits in: automating the Internet.
spent the last two years programming Y2K fixes in COBOL?” or “What if I was a PRO-
LOG programmer doing scientific research for a number of years?” Would someone
working with language X understand a certain explanation or example? When the answer
was positive, I felt confident that I had given you fair consideration.
This is a book written for every programmer. Although it has notes for a couple of the
larger potential groups of readers, C++ and Java programmers, it considers all program-
mers. It’s basic enough for you to see every aspect of C# that’s possible, yet it’s suffi-
ciently advanced to provide insight into the modern enterprise-level tasks you deal with
every day. I hope this book leaves you with a sense that you now have a valuable new
tool in your backpack to develop the Web services and distributed solutions that are ulti-
mately our destiny.
Part I: C# Basics
Part I provides the most basic elements of C# language syntax. It begins by introducing
the environment C# operates in and then showing how to create a couple simple C# pro-
grams. The different C# types and how they’re used to create expressions and statements
are covered. There is a chapter on controlling program flow with branching and iteration.
After enough material has been covered so that the reader understands a moderately
sophisticated program, there is a chapter on how to debug C# programs.
• Chapter 1 C# does not operate in a typical environment where programs are
compiled directly to machine code. It runs in a virtual execution system that man-
ages how the code runs. There are several technologies that enable this environ-
ment to operate the way it does. C# is also being submitted as an open standard.
The material is purposely brief, so you can quickly dive into the main purpose of
the book, writing C# code.
3
INTRODUCTION
• Chapter 2 The basics of C# include how to build a simple program, basic syn-
tax, and information on C# types. C# syntax and types are much like those of its C
and C++ parent languages.
• Chapter 3 Central to computing in any language is the ability to manipulate data
with expressions. C# includes an entire suite of unary, binary, and ternary expres-
sions. Highlights include forming expressions, operator precedence, and working
with enum and array types.
• Chapter 4 Rounding out basics of the C# language are several constructs allow-
ing control of program flow. Besides the traditional if and select statements and
while and for loops, there is an explanation of the new foreach loop. I even touch
upon the infamous goto statement.
• Chapter 5 Advanced programmers, please bear with me. I sincerely believe
that debugging is so important, especially to intermediate programmers, that
there is an entire chapter dedicated to it. There is also an introductory section on
pre-processing directives.
3 Writing C# Expressions 47
IN THIS CHAPTER
• The Common Language Infrastructure
(CLI) 12
• Standardization 15
• Where C# Fits In 17
C# Basics
12
PART I
Metadata provides the capability for code to be self-describing. This is a powerful con-
1
cept, enabling components to expose their capabilities for use in various tools. Metadata
also allows program capabilities to be dynamically implemented through runtime method
ENVIRONMENT
calls. This is used for any late bound requirements and for software development tools.
THE C#
Through the CTS, CLS, and metadata, the CLI is able to support a robust Virtual
Execution System (VES). Services provided by the VES include managed code execution
and security. The VES operates on Common Intermediate Language (CIL) code pro-
duced by CLI-compliant compilers.
Note
Managed code refers to the way the VES handles memory allocation and code
execution. The VES has full control over managed code in order to provide secu-
rity. Managed code is compiled to an intermediate language, CIL, where it can
be verified by the VES. Traditional languages such as C and C++ are considered
unmanaged because they compile to machine code and have only those con-
trols a programmer establishes in the code.
All C# code is managed code.
An often-confused concept is the difference between managed code and unsafe
code. C# has a way of allowing programmers to use certain language elements
that are considered unsafe. These are language elements such as pointers and
memory allocation on the stack. One of the primary advantages of unsafe code
is to interface with APIs that require pointers in their parameters or within a
structure. Although there is potential to do unsafe things in unsafe code, even
unsafe code is managed.
Note
C# Basics
14
PART I
Note
Currently there are plans to ship four languages with .NET. These languages are
Visual Basic.NET, Visual C++.NET, Visual Jscript.NET, and (the one near and dear
to my heart) Visual C#.NET. Currently there are approximately 50 other ISVs that
are considering porting languages to the .NET platform.
FIGURE 1.1
CLI profiles.
ENVIRONMENT
of libraries, enabling support for a diverse range of services. A typical environment for
THE C#
this profile would be those intended for desktop or server deployment.
Appendix B, “The .NET Frameworks Class Libraries,” contains an overview of libraries
available and details the profiles they are part of.
Standardization
On October 31, 2000, Hewlett-Packard, Intel, and Microsoft jointly submitted C# and the
CLI to the European Computer Manufacturers Association (ECMA) for standardization.
The purpose of this was to establish a standard for future implementations of C# and
the CLI.
This is significant because historically speaking, most languages are created, released,
and available for years before standardization occurs. Then after multiple incompatible
versions have been implemented, vendors play catch-up to mitigate the effects of non-
standard portions of their implementations. Furthermore, applications written with
nonstandard implementations break and need modification to comply with the new
standards-based compilers upon release. In a rare historical occurrence, this is an
opportunity to have a language open to a public standards organization (such as ECMA)
from the beginning, creating an optimistic outlook for a new entry in cross-environment
program compatibility.
Of significant note is the recent mass adoption of the Java programming language/
environment. Although this is not a public standard, it still proves the interest in a
standardized environment with a philosophy of “write once, run anywhere.” I believe
there is great potential for the C# programming language and CLI environment to
achieve these goals also. Standardization increases the probability of cross-environment
adoption of a common standard.
The primary focus in standardizing the CLI and C# is for cross-language compatibility—
so that anyone can write a component in any .NET-compatible language and that same
component may be reused in any other .NET-compatible language. The term reuse
relates to any object-oriented employment of a component to include inheritance, con-
tainment and encapsulation, and polymorphism.
The CLI also promotes standardization by implementing common Internet protocols and
standards into its core libraries. The technologies of HTTP, SOAP, and XML are well
known and accepted. They enable CLI applications such as Web services to interoperate
C# Basics
16
PART I
in a platform-neutral manner with Web services created with any other technology. The
CLI is simply a specification of a framework that enables developers to create standards-
compatible components that interoperate with any other standards-compatible component
implementations.
FIGURE 1.2
The .NET
architecture.
Libraries
The .NET libraries have much more functionality than the CLI specification. Extra
enhancements include ASP.NET (Web application programming tools), Windows Forms
(interface to the Windows operating system), and ADO.NET (database connectivity
tools). The goals of the .NET libraries were to use common Web standards as their foun-
dation, unify disparate application models, enhance simplicity, and make the entire
framework factored and extensible.
The C# Environment
17
CHAPTER 1
Languages 1
The .NET Framework software development kit ships with four programming languages:
ENVIRONMENT
C++, Visual Basic, JScript, and C#. Many more third-party companies have begun work
THE C#
on additional .NET-compatible languages. What makes the .NET support for languages
so unique is that all languages are first-class players. The goal is to make them work
interchangeably. While this is mostly true, there are differences between languages and
the user must ultimately decide which language best suits his needs. This book will show
how to use C# in filling a very wide range of development requirements.
Where C# Fits In
Traditionally, languages and their libraries have been referred to as single entities.
Programmers knew they were separate, but since the library only worked with that lan-
guage, there was no harm in saying certain functionality was a part of a certain language.
With C# this is different. The libraries belong to the CLI. The language itself is very
simple and it uses the CLI libraries. These are the same libraries used by other CLI-
compliant languages. Therefore, they can’t be considered specifically C# libraries.
C# played a significant part in the development of the .NET Framework libraries. Of
course, there are other library modules written with two other CLI-compliant languages:
Visual Basic.NET and Managed C++. This means that while programming in C# and
using CLI libraries, the classes being used are very likely written in other languages.
Since this is totally transparent, it should be of no concern. However, it does prove that
the cross-language philosophy of the CLI specification does indeed work.
Summary
This chapter introduced the Common Language Infrastructure (CLI). The CLI consists of
a Common Type System (CTS), a Common Language Specification (CLS), metadata,
and a Virtual Execution System (VES).
The significance of standardization and how it could benefit the software development
community was discussed.
I also talked about the .NET Architecture. The software in this book was developed with
.NET.
Finally, there was a discussion on where C# fits into the CLI. C# is a new object-oriented
language, designed from the ground up to support the component concepts intrinsic to
the CLI. The C# programming language played a major role in the development of the
.NET Frameworks.
Getting Started
CHAPTER 2 with C#
IN THIS CHAPTER
• Writing a Simple C# Program 20
• Comments 22
• Style 26
• Basic C# Types 28
• Definite Assignment 37
• Basic Conversions 38
• Arrays 40
This chapter starts by creating a simple, minimal C# program that will give you a feel for
what C# looks like and will be a stepping-stone to more features. This chapter includes
instructions on how to compile this program. When needed, additional compilation fea-
tures will be presented. Appendix A has a detailed list of compilation options.
This chapter also provides coverage of the C# data types. It tells about the various types
C# provides. There will be plenty of examples of declarations and the kinds of data that
can be stored. It also covers the relationship between types and how to make conver-
sions. The chapter will finish by showing various ways to provide input and output for
programs.
Line 7 of Listing 2.1 shows a class declaration. Classes are what C# uses to declare or
define objects. They describe the attributes and behavior of an object. An object is any-
thing that has attributes and behavior. While classes are definitions, objects are the actual
entities that exist when the program runs. There can normally be many objects based
upon a single class declaration. Objects are the building blocks of the C# programming
language. C# is an object-oriented programming language; therefore, it has a starting
object. That’s what this class represents—the starting object of this program.
Getting Started with C#
21
CHAPTER 2
The Main() method is located inside of a class instead of by itself. Also, the
method’s first letter is capitalized.
C# is case sensitive. The first letter of the Main() method is capitalized. Also, the
C# Main() method can declare return types of both int and void. 2
GETTING STARTED
WITH C#
The identifier, or name, of a class follows the class keyword. This class is called
HowdyPartner. Classes can have almost any name, but whatever the name, it should be
meaningful. Details of identifiers and keywords are described in a couple more sections.
Left and right braces indicate the beginning and ending, respectively, of a block. In
Listing 2.1, the beginning of the class block starts on line 8 after the HowdyPartner iden-
tifier, and the end of the class block is on line 15, by itself. In C#, it’s common to begin
and end portions of programs with curly braces.
There’s a method declaration on line 10. This is the Main() method. Every program has a
Main() method that is the starting point for the program. When the program begins, this
is the first method called.
There are a couple identifiers in front of the Main() method. C# Main() methods always
have a static modifier. In C# there are two types of objects—static and instance.
Instance objects are formally declared, and there can be many of the same type with dif-
ferent attributes. However, there can be only a single copy of a static object in existence
for a given program. The only way to execute a method without an instance of its con-
taining object is if that method is static. Since no instance of the starting class exists as
an object when the program starts, a static method must be called. This is why the
Main() method is static.
The other identifier is void. This is actually the Main() method’s return value. Return
values are useful for returning program status to a calling program or utility when a pro-
gram exits. When void is specified, the method does not return a value. In this case, the
Main() method does not return a value. Besides returning a void, the Main() method
could return an integer.
C# Basics
22
PART I
Within the body of the Main() method on line 13 is a single statement that causes the
words “Howdy, Partner!” to be written to the console screen. The statement System.
Console.WriteLine(“Howdy, Partner!”) writes text to the console screen. Figure 2.1
shows the output.
FIGURE 2.1
Output from the
HowdyPartner
program.
Comments
There are three types of commenting syntax in C#—multi-line, single-line, and XML.
Multi-Line Comments
Multi-line comments have one or more lines of narrative within a set of comment delim-
iters. These comment delimiters are the begin comment /*and end comment */ markers.
Anything between these two markers is considered a comment. The compiler ignores
comments when reading the source code. Lines 1 through 4 of Listing 2.1 show a multi-
line comment:
1: /*
2: * FileName: HowdyParner.cs
3: * Author: Joe Mayo
4: */
Some languages allow embedded multi-line comments, but C# does not. Consider the
following example:
1: /*
2: Filename: HowdyPartner.cs
3: Author: Joe Mayo
4: /*
5: Initial Implementation: 04/01/01
6: Change 1: 05/15/01
7: Change 2: 06/10/01
8: */
9: */
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of The man who
knew everything
This ebook is for 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.
Language: English
By RANDALL GARRETT
B. J. Holly, office manager for Starr & Sons, Inc., flipped a switch on
his desk intercom. "Where is Merriwether?" he snapped. "That boy
was supposed to have picked up these letters for filing half an hour
ago. I can't wait any longer."
"Mr. Merriwether phoned in this morning, sir," said the secretary's
voice. "He said he was a little ill, and he'd be late. He—oh! Just a
moment, sir; he just came in."
"Send him in here!" ordered B. J. Holly.
Mr. Holly frowned at Phil Merriwether as soon as the door opened.
"Under the weather a bit, eh, Merriwether?"
Phil nodded. "Yes, sir. My head feels queer."
Mr. Holly suppressed an impulse to remark that he wasn't at all
surprised. In his estimation, anyone with a head like Merriwether's
would feel odd all the time. But Mr. Holly, although somewhat
tyrrannical, and definitely a stuffed shirt, was not basically cruel, so
he said nothing that vicious.
"A bit of a hangover, perhaps?" he asked suspiciously.
Phil was picking up the papers for the file room. "No, sir," he said
absently. "A hangover is caused by the toxic effects of various
isomeric forms of higher alcohols and other impurities normally
present in alcoholic beverages, plus a depletion of vitamins,
especially B-one, in the system. I don't drink."
"I—uh—I see." But Mr. Holly did not see. He was totally baffled. He
watched in astonishment as Phil Merriwether walked out the door of
the office.
Merriwether, himself was slightly bemused. How had he done it? He
knew perfectly well what he was saying; a full night of thinking had
managed to bring to him the realization that something—he knew not
what—had happened to his memory. It seemed to him that there
must be something he could do with it, but he didn't quite know what.
The decision was practically forced upon him just before lunchtime.
He was putting on his coat to go out for lunch when B. J. Holly
stepped out of his office. The office manager was preparing to have
lunch with an out-of-town buyer, and as he stepped up to the visiting
fireman, he said: "Well, as General Pershing said: 'Lafayette, we are
here!'" He chuckled at his own wit, paying no attention to
Merriwether.
"I beg your pardon, sir," said Phil, "but the general never said that; as
a matter of fact, he said later that it was put into his mouth by a
newspaperman. He said—"
B. J. glowered at him. An office boy, even if he is thirty-four years of
age, is not supposed to contradict his superior.
"Look, son," said B. J., "I happened to be there. I was only a private,
but I happened to be standing right next to him."
"That's impossible, sir," Phil said quietly. "According to Federal
records, you were born on April second, nineteen-oh-four. You were
only fourteen years old at the time. You have no military record with
the United States Army."
The out-of-town buyer suppressed a snicker. B. J. Holly turned
purple and said: "I'll see you after lunch."
After lunch, Philip Merriwether lost the job he had held for five years.
At seven o'clock that night, he sat in a small bar, sipping
disconsolately at a glass of Coca-Cola. Not knowing where he was
going to get another job, he was trying to drown his thoughts in
soda-water and television. The show on the screen was "You Can't
Lose," a quiz show produced by the Boltman Automobile
Corporation.
The quizmaster was grinning sardonically at the hapless contestant.
"You have arrived at the fifty thousand dollar question," he said.
"Since you chose geometry as your category, the question will be on
that subject. Are you ready?"
The contestant nodded unhappily.
"All right, here's the question: What is the value of pi to eight decimal
places?"
Before the contestant could say a word, Phil muttered: "Three point
one four one five nine two six five—plus." He didn't notice what the
contestant said, but the quizmaster shook his head in mock sorrow.
"I'm sorry, sir, but the correct answer is: three point one four one five
nine two six five. Better luck next time."
The coarse, unshaven man standing next to Phil looked at him in
awe. "Hey, buddy," he said, "that's the ninth time you've answered
right. Why don't you get on that program and make yourself some
dough?"
Phil blinked at his Coke and thought it over. Then his face
brightened. "Yeah," he said, grinning, "why don't I?"
It took him three weeks to get into the studio, and by that time, his
severance pay was almost gone. He was nearly broke, and had no
prospects of a job. He had to make good.
By pure chance, he was chosen as one of the first contestants. The
quizmaster beamed at him pleasantly.
"You understand the rules, don't you?" he asked. "All you have to
do...."
He went on, but Phil didn't hear him; he was too scared. When the
first question popped up, he said: "I beg your pardon?"
"I'll repeat the question," the quizmaster said. "You have chosen the
'General Category.' That pays twice as much, but it means I can ask
you any question I like. The first one was: 'Who were the Essenes?'"
Since the General Category questions paid off twice as much as the
Restricted Categories, they were about four times as hard. But that
didn't bother Phil Merriwether in the least.
"The Essenes," he said, "were an obscure Jewish sect which
flourished during the time of Christ, from before 100 B.C. to about 70
A.D. They are believed to be instrumental in the composition of the
so-called Dead Sea Scrolls, which were discovered—"
"That's enough," the quizmaster said. "You've given the right
answer!" The orchestra sounded a chord. Applause followed.
"Second question: Listen carefully. Henry the Seventh's title was the
same as the title of the last Tudor king of England; the last Tudor
king had the same name. What was the name of the last Tudor ruler
of England?" The quizmaster smirked happily; the question was a
trick one.
"Elizabeth the First was the last Tudor ruler," said Phil. "The last
Tudor king was Henry the Eighth."
Naturally, the answer was right.
"Very good," said the quizzer. "Number three: what does
pneumonoultramicroscopicsilicovolcanoconiosis mean?"
Phil closed his eyes and listened to the little voice inside his head.
He said: "It is an inflammation of the lungs caused by tiny particles of
rock dust; it is commonly known as 'silicosis' or 'miner's
consumption.'"
The quizmaster looked almost shocked, but, good showman that he
was, he managed to keep a bland expression on his face.
"That's right!" he bellowed.
Phil Merriwether grinned happily. He didn't know how it had come
about, but, somehow, something had filled his head full of all kinds of
amazing facts. It didn't matter what the question was, all Phil had to
do was think about it, and the answer was in his memory. He smiled,
waiting for the next question.
"You've come to the $25,000 question," said the MC. "If you want to
go on, you will have to be put in a soundproof booth so that you
won't be prompted by the audience. If you want to come back next
week—"
"I'll take it now," said Phil Merriwether.
So they put him in a soundproof booth. All he could hear was the
announcer's voice.
Phil smiled to himself. Twenty-five thousand dollars so far! It was
fantastic! He'd never have to work again!
He answered the next question easily. Fifty thousand dollars!
Fantastic!
The announcer said: "What is the mathematical formula for the
world's most powerful weapon?"
Phil grinned. That was simple. "The formula is: i over b times a
equals pi to the i times e over mu," he said.
"Ohhh, I'm sorry, sir," the announcer said sadly. "The basic formula
for the manufacture of the atomic bomb is: E equals m times c
squared. But you still have your fifty thousand dollars;
congratulations and better luck next time."
Phil Merriwether blinked. He could hardly believe it. He knew his
answer was right. There must be a mistake. But no amount of
argument did him any good. Within fifteen minutes, he was out on
the street. The studio had promised that the check would be
deposited to his account in the morning. Phil shrugged and went
home.
Phil Merriwether sat in the deepest, most secluded cell of the United
States Government's greatest security prison. He sat and thought,
his brain working more furiously than it had ever worked before. He
was tired and haggard from loss of sleep, and worn out from hours of
questioning. But that wasn't the worst of it. The entire top brass of
the government was in a stew over what they should do with Philip
Merriwether. The FBI could get no evidence on him; there was
nothing to prove he was a spy. And even if there had been, the case
could never be brought to court. Phil knew too much.
"Good heavens," he moaned, "how did I ever get into a fix like this?"
"You're a blabbermouth," he answered himself. "If you hadn't told
them all that stuff, you'd never have been in this jam!"
But how did he know all the information about the U.S.
Government's most top secret plans? It must have had something to
do with that fainting spell. How did that explain it?
"Well," he said to himself, "you've got a lot of information—use it!"
So he sat on the edge of the hard bunk, his mind searching for some
clue as to what had happened to him.
He was still sitting like that when the Secretary of Defense and the
President of the United States walked into the cell some hours later.
He had thought about all the data he had on every subject from
anthropology to zoology. It had something to do with neurology and
radiation physics, he was sure, but what?
And then, quite suddenly, the pieces clicked together.
When the Chief Executive walked into his cell, Phil beamed happily.
"I'm pleased to meet you, Mr. President."
The President frowned. "I must admit, Mr. Merriwether, that it is a
pleasure to meet you, too. I admire such abilities as yours, although I
also wish you had never been born. It seems you know more about
our national defense than I do."
"It's amazing," said the Secretary. "According to the FBI, this
fiendishly clever man has been masquerading as an ordinary
blockhead for more than thirty years. No one suspected his true
genius. The only thing we can't figure out is why he shot off his
mouth over television."
Phil said: "Mr. Secretary, I didn't think about it. I didn't realize it was
so secret. I'm sorry. But I think I can show you how I got all this
information."
The President looked blank. "Show us? You mean you're willing to
betray your espionage system?"
"I don't have any spy system," Phil said. "Will you give me a pencil
and a piece of paper?"
The Secretary handed him a notebook and a ball-point pen, and Phil
began to write. "According to File X-99761, in the War Department's
Ultra Top Secret Section, a Dr. Heinrich Wolstadt is working on a
secret communication device. I'm putting some formulas on this
paper. Ask Dr. Wolstadt what effect this particular wave form would
have on the human brain."
The Secretary of Defense and the President looked at each other.
"I guess we might as well," the President said.
It was several hours later that Dr. Wolstadt was rushed into Phil's
cell. He was so excited that his German accent became much
heavier than usual.
"Is this the chentleman? Ach! It's amazing! How did it happen? You
were standing right in the path of the ray, nein?"
"I think so, Dr. Wolstadt. Didn't you suspect what effect the beam
might have had?"
"Never!" said the physicist. "Not until I saw your mathematics. It's
unbelievable to think this could happen!"
"For Heaven's sake!" said the President. "What happened?"
Wolstadt turned around to face the Chief Executive.
"It's very simple. The derivation of the Q-beam that I have been
working on got out of control for a second. It went through all my
files, and all the files in the Pentagon, and Heaven only knows what
else. It picked up all that information and put it in Mr. Merriwether's
mind!"
"Amazing!" said the President.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookgate.com