100% found this document useful (5 votes)
18 views

(eBook PDF) Fundamentals of C# Programming for Information Systems 2nd Editioninstant download

The document is an overview of the eBook 'Fundamentals of C# Programming for Information Systems, 2nd Edition,' which provides a comprehensive introduction to C# programming concepts for students in information systems and related fields. It includes updates such as new chapters on web application development and object-oriented programming, along with hands-on tutorials and exercises. The book is designed for beginners and emphasizes graphical user interfaces using Visual Studio, with additional resources available for both students and instructors.

Uploaded by

grittygorda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
18 views

(eBook PDF) Fundamentals of C# Programming for Information Systems 2nd Editioninstant download

The document is an overview of the eBook 'Fundamentals of C# Programming for Information Systems, 2nd Edition,' which provides a comprehensive introduction to C# programming concepts for students in information systems and related fields. It includes updates such as new chapters on web application development and object-oriented programming, along with hands-on tutorials and exercises. The book is designed for beginners and emphasizes graphical user interfaces using Visual Studio, with additional resources available for both students and instructors.

Uploaded by

grittygorda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

(eBook PDF) Fundamentals of C# Programming for

Information Systems 2nd Edition instant download

https://ebooksecure.com/product/ebook-pdf-fundamentals-of-c-
programming-for-information-systems-2nd-edition/

Download more ebook from https://ebooksecure.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebooksecure.com
to discover even more!

(eBook PDF) Fundamentals of C# Programming for


Information Systems 2nd Edition

http://ebooksecure.com/product/ebook-pdf-fundamentals-of-c-
programming-for-information-systems-2nd-edition-2/

(eBook PDF) Fundamentals of Information Systems 9th


Edition

http://ebooksecure.com/product/ebook-pdf-fundamentals-of-
information-systems-9th-edition/

(eBook PDF) Fundamentals of Information Systems 8th


Edition

http://ebooksecure.com/product/ebook-pdf-fundamentals-of-
information-systems-8th-edition/

Fundamentals of Information Systems 9th Edition Ralph


Stair - eBook PDF

https://ebooksecure.com/download/fundamentals-of-information-
systems-ebook-pdf/
Essentials of MIS (Management Information Systems),
15th Global Edition Kenneth C. Laudon - eBook PDF

https://ebooksecure.com/download/essentials-of-mis-management-
information-systems-15th-global-edition-ebook-pdf/

Essentials of MIS (Management Information Systems),


15th Global Edition Kenneth C. Laudon - eBook PDF

https://ebooksecure.com/download/essentials-of-mis-management-
information-systems-15th-global-edition-ebook-pdf-2/

(eBook PDF) Management Information Systems for the


Information 9th

http://ebooksecure.com/product/ebook-pdf-management-information-
systems-for-the-information-9th/

Fundamentals of Ecosystem Science 2nd Edition Kathleen


C. Weathers - eBook PDF

https://ebooksecure.com/download/fundamentals-of-ecosystem-
science-ebook-pdf/

(eBook PDF) Fundamentals of Communication Systems,


Global Edition 2nd Edition

http://ebooksecure.com/product/ebook-pdf-fundamentals-of-
communication-systems-global-edition-2nd-edition/
6.5 Getting User Input from Controls ................................................................................................... 183
6.6 Working with ComboBoxes............................................................................................................ 186
6.7 Working with ListBoxes ................................................................................................................. 196
6.8 Windows Presentation Foundation (WPF) ..................................................................................... 201
Exercises ............................................................................................................................................... 203
Chapter 7: Arrays ................................................................................................205
7.1 Introduction to One-Dimensional Arrays ....................................................................................... 205
Tutorial 1: Working with 1-D Arrays: Test Scores Application ........................................................... 208
7.2 Assigning a Value to an Element of an Array................................................................................. 211
7.3 Accessing Elements of an Array Using the Index .......................................................................... 212
7.4 Accessing Elements of an Array Using the foreach Loop .............................................................. 215
7.5 Copying an Array............................................................................................................................ 217
7.6 Looking Up Values in an Array ...................................................................................................... 221
Tutorial 2: Lookup Units Sold Using 1-D Arrays................................................................................. 222
Exercises ............................................................................................................................................... 224
Chapter 8: Sequential Files and Arrays.............................................................226
8.1 Introduction to Text Files................................................................................................................ 226
Tutorial 1: Reading Text Files .............................................................................................................. 229
8.2 Splitting a Row: Split Method ........................................................................................................ 231
8.3 Reading Data from Files into Arrays .............................................................................................. 234
8.4 Additional Methods of Arrays ........................................................................................................ 241
Tutorial 2: Looking Up Phone Numbers Using Arrays ........................................................................ 242
Tutorial 3: Using a ComboBox to Select the Search Name .................................................................. 246
8.5 Writing to Text Files ....................................................................................................................... 248
Tutorial 4: Writing Scores to Text File ................................................................................................. 248
8.6 SaveFileDialog Control .................................................................................................................. 255
8.7 Passing Arrays to Methods ............................................................................................................. 259
Tutorial 5: Passing Arrays to Compute Average .................................................................................. 259
8.8 Two-Dimensional (2-D) Arrays ...................................................................................................... 263
Tutorial 6: 2-D Array to Find the Sales for a Product........................................................................... 267
Exercises ............................................................................................................................................... 271
Rentals Assignment 2 ........................................................................................................................... 272
Help Desk Assignment 2 ...................................................................................................................... 274
Chapter 9: Collections .........................................................................................276
9.1 Introduction to Collections.............................................................................................................. 276
9.2 List<T> Collection .......................................................................................................................... 278
Tutorial 1: Looking Up Sales Data Using a List ................................................................................... 279
9.3 Dictionary<TKey, TValue> Collection .......................................................................................... 285
Tutorial 2: Dictionary with Product# as Key and Price as Value ......................................................... 287
Tutorial 3: Dictionary with Product# as Key and Sales Array as Value ............................................... 293
Exercises ............................................................................................................................................... 297
Chapter 10: Graphical User Interface: Additional Controls...........................298
10.1 ListView: Features ........................................................................................................................ 298
10.2 Adding Items to ListView ............................................................................................................. 299
Tutorial 1: Selecting a Show from a ListView ..................................................................................... 302
10.3 Accessing Data from a ListView .................................................................................................. 302
10.4 Forms with Tab Pages ................................................................................................................... 308
Tutorial 2: Multipage Form with TabControl ....................................................................................... 308
Exercises ............................................................................................................................................... 310
Chapter 11: Multi-form Applications and Menus ............................................312
11.1 Introduction ................................................................................................................................... 312
11.2 Accessing an Existing Form from Another................................................................................... 313
Tutorial 1: Multi-form Financial Planning Application ........................................................................ 315
11.3 Sharing a Method between Multiple Forms .................................................................................. 318
Tutorial 2: Sharing the LoadDictionary Method between Forms ......................................................... 319
11.4 Closing a Parent Form .................................................................................................................. 325
11.5 Menus............................................................................................................................................ 328
11.6 ToolStrips...................................................................................................................................... 332
Exercises ............................................................................................................................................... 334
Chapter 12: Databases .........................................................................................335
12.1 Introduction ................................................................................................................................... 336
12.2 Creating Database Objects ............................................................................................................ 336
Tutorial 1: Display Employee Records Using the Wizard .................................................................... 337
12.3 Displaying Data in a DataGridView ............................................................................................. 340
12.4 Accessing Data Items from a DataGridView ................................................................................ 346
12.5 Displaying Data in Details View .................................................................................................. 349
12.6 Finding the Record for a Selected Key ......................................................................................... 351
Tutorial 2: Find Employee Records Using the Wizard ......................................................................... 352
12.7 Selecting a Group of Records Using the Binding Source ............................................................. 356
12.8 Selecting Records Using the Table Adapter ................................................................................. 362
Tutorial 3: Parameter Query to Select Records..................................................................................... 363
12.9 Untyped Datasets: Displaying Records......................................................................................... 365
Tutorial 4: Display Records Using Untyped Datasets .......................................................................... 366
12.10 Untyped Datasets: Selecting Records ......................................................................................... 375
Tutorial 5: Select Records Using Untyped Datasets ............................................................................. 377
12.11 Untyped Datasets: Add/Edit/Delete Records .............................................................................. 384
Tutorial 6: Add/Edit/Delete Using Untyped Datasets........................................................................... 385
12.12 Command Object and DataReader .............................................................................................. 394
Tutorial 7: SqlCommand and SqlDataReader to Work with Tables ..................................................... 396
Exercises ............................................................................................................................................... 405
Rentals Assignment 3 ........................................................................................................................... 407
Help Desk Assignment 3 ...................................................................................................................... 407
Chapter 13: Object-Oriented Programming .....................................................414
13.1 Introduction to Objects and Classes .............................................................................................. 415
13.2 Classes versus Objects .................................................................................................................. 415
13.3 Information Hiding (Encapsulation) ............................................................................................. 417
Tutorial 1: Create an Employee Class................................................................................................... 419
13.4 Properties ...................................................................................................................................... 423
Tutorial 2: User Interface and Properties .............................................................................................. 426
13.5 Calling Methods (Sending Messages to Objects) ......................................................................... 434
Tutorial 3: Calling Methods and Passing Data between Forms ............................................................ 435
Exercises ............................................................................................................................................... 448
Chapter 14: Inheritance ......................................................................................450
14.1 Introduction to Inheritance ............................................................................................................ 451
14.2 Implementing Inheritance ............................................................................................................. 452
Tutorial 1: Creating Subclasses ............................................................................................................ 454
14.3 Using Subclasses and Super Classes............................................................................................. 458
14.4 Overriding Methods ...................................................................................................................... 459
Tutorial 2: Implementing the GrossPay Method................................................................................... 462
14.5 Polymorphism ............................................................................................................................... 467
Tutorial 3: Dynamic Dispatch and the ToString Method...................................................................... 468
14.6 Abstract Classes and Interfaces..................................................................................................... 472
Tutorial 4: Interfaces ............................................................................................................................. 473
14.7 Using Interfaces to Sort Collections ............................................................................................. 480
Tutorial 5: Sorting Employees .............................................................................................................. 483
14.8 Access Modifiers in C# ................................................................................................................. 486
Exercises ............................................................................................................................................... 488
Chapter 15: Introduction to Web Applications Development .........................491
15.1 Introduction to Web Applications ................................................................................................. 491
15.2 Creating a Single-Page ASP.NET Website................................................................................... 496
Tutorial 1: Developing a Simple Web Page: Ice Cream Cost ............................................................... 496
15.3 Introduction to HTML .................................................................................................................. 502
15.4 Working with Web Server Controls.............................................................................................. 506
15.5 Validating Data Using Validation Controls .................................................................................. 517
Exercises ............................................................................................................................................... 522
Chapter 16: Web Development: Multipage and Database Applications.......523
16.1 Accessing Databases from Web Forms ........................................................................................ 523
Tutorial 1: Accessing a Database: Theater Tickets Application ........................................................... 524
16.2 Preserving Data during Postbacks Using View State ................................................................... 538
16.3: Multipage Websites and Session State ........................................................................................ 543
16.4 Setting a Page to Its Previous State ............................................................................................... 551
Exercises ............................................................................................................................................... 557
Appendix A: Binary Files ....................................................................................559
A.1 Writing to Binary Files .................................................................................................................. 559
Tutorial: Working with Binary Files ..................................................................................................... 559
A.2 Reading Binary Files ...................................................................................................................... 560
Appendix B: Creating a Database ......................................................................562
Tutorial: Creating HR Database............................................................................................................ 562
Appendix C: Answers to Review Questions ......................................................564
Appendix D: HTML Elements ............................................................................584
Index ......................................................................................................................586
Preface
Mission of the Text
Welcome to Fundamentals of C# Programming for Information Systems. This book teaches the
fundamentals of programming in C# to provide a solid foundation to build business and other real-world
applications. Programming concepts are discussed in the context of familiar practical applications that use
graphical interfaces.

New to This Edition


A key goal of the new edition was to add significant content so that the book could be used in a two-
course sequence in programming. Four new chapters have been added: Two chapters that provide a
comprehensive introduction to web applications development, and two other chapters on the concepts and
practice of object-oriented programming, including inheritance.
Several other updates were made based on feedback from instructors: a second set of three comprehensive
assignments (in chapters 3, 8, and 12), additional end-of-chapter exercises, and learning objectives for
each chapter.

Target Audience
This book is designed for introductory programming courses in IS/MIS, CIS and IT. This book also
would fit into a computer science curriculum with an introductory course that uses a GUI-based
application-oriented approach to teach programming concepts. The breadth and depth of coverage makes
this book suitable for a two-course sequence, particularly when students come to the first course with no
programming background and a slower pace is desired. An approach in a two-course sequence would be
to do in-depth coverage of topics like collections, databases, object-oriented programming, web
development, and others presented in later chapters only in the second course.

Key Features
A key feature of the book is that programming concepts are introduced in small chunks through examples
and illustrations accompanied by hands-on tutorials. The tutorials, which are interspersed with the
concepts, help students apply and explore what they learn immediately. Additionally, review questions
and exercises within the chapters enhance student interest and learning.
Although the book is written for beginners, it is thorough and concise. Graphical illustrations and
screenshots are used throughout the book to enhance learning for both beginners and experienced
students.
Windows forms are used from the beginning to provide GUI-based as opposed to console-based interface.
This book builds graphical user interfaces and code in the .Net environment using Visual Studio. You are
encouraged to use the current free version, Visual Studio Community 2017. Earlier versions, including
Visual Studio 2015, Visual Studio Express and Visual Studio 2013, generally work well, except that you
won’t be able to run a few programs that use certain features available only in C# version 7.1 or greater.
ii

Supplements
For Students: Tutorial_Starts.zip file that contains
o Partially completed projects for tutorials
o Data files/databases used in projects

You may download the Tutorial_Starts.zip file from


http://www.prospectpressvt.com/titles/c-sharp-programming/student-resources/

For Instructors: Instructor resources include


o Completed tutorials
o PowerPoint slides for all chapters
o Test bank
o Partially completed projects for tutorials
o Data files/databases used in projects

To access instructor resources, please complete the request form at


http://www.prospectpressvt.com/faculty-resources/instructors-material/

Installing Visual Studio


You may download Visual Studio Community 2017 from the following website:
https://www.visualstudio.com/downloads/

To install Visual Studio, open the downloaded .exe file and run it.

Overview of the Content and Organization


Every possible sequence of topics seems to put constraints on the quality of illustrative examples and
applications that can be used in a chapter. The organization of chapters in this book attempts to minimize
such problems and to enhance the ability to build on prior chapters. However, except for the foundational
Chapters 1–5, there is significant flexibility in choosing specific topics and the depth of coverage. As
suggested by the dependencies summarized below, there is some flexibility in the sequencing too.
Chapters 1–5 cover the Visual Studio environment and introductory programming concepts, including
methods. These chapters, which provide the foundational knowledge, should be covered in sequence
before other chapters, though certain topics like working with dates and times (section 2.4) may be
postponed or skipped.
Chapter 6 presents the application of the GUI controls ScrollBars, RadioButtons, CheckBoxes,
ComboBoxes and ListBoxes.
Chapter 7 provides a detailed presentation of one-dimensional arrays, and Chapter 8 presents accessing
sequential files and using arrays in combination with files. Chapter 6 is not a prerequisite for Chapters 7
or 8. GUI is presented early on in Chapter 6 to motivate students with more interesting graphical
interfaces. It should be noted that the comprehensive assignment (Assignment 2) specified at the end of
Chapter 8 requires the use of several GUI controls.
Chapter 9 introduces collections, and discusses the List and Dictionary collections in more detail. Chapter
8 (“Sequential Files and Arrays”) is a prerequisite for this chapter. Because of the close relationship
iii

between collections and arrays, collections are presented in this book immediately following Chapter 8 on
arrays.
Chapter 10 discusses the application of ListView and TabControl. The dependency of this chapter on
Chapter 9 (“Collections”) is very low. The prerequisite for this chapter includes Chapters 6 and 8.
Chapter 11 presents multiform applications, Menus and ToolStrips. This chapter has some dependency on
previous chapters, except Chapter 10.
Chapter 12 provides in-depth coverage of accessing databases from C# programs. Chapter 6 is a
prerequisite for this chapter. In addition, the ListView control presented in Chapter 10 is used in an
example in the last part of this chapter, and it is required in the third comprehensive assignment
(Assignment 3) at the end of this chapter. Assignment 3 also requires the use of MainMenu control
discussed in Chapter 11. Other than that, the dependence of Chapter 12 on Chapters 7–11 is relatively
low.
Chapter 13 provides an introduction to object-oriented programming (OOP) principles and techniques.
The initial part of this chapter may be used for an introduction to OOP early in the semester.
Chapter 14 describes the concept of inheritance, implementation of inheritance, subclasses and super
classes, overriding methods and polymorphism. Chapter 13 is a prerequisite for this chapter, and it also
relies on collections from Chapter 9.
Chapter 15 presents the concepts of web applications development, and develops simple web applications
using the ASP.Net platform in the Visual Studio environment. Only the basic programming knowledge
presented in Chapters 1–3 is required for this chapter.
Chaper 16 describes how to access SQL Server databases and develop multipage web projects. Basic
programming concepts presented in Chapters 1–6, the concept of collections from Chapter 9, and basic
database concepts including binding controls to a database and filtering records (Chapter 12) are used in
building the application.
iv

Acknowledgments
I am thankful for the valuable assistance provided by many people in the preparation of this book. I wish
to thank Dr. Jakob Iversen, The University of Wisconsin–Oshkosh, for authoring Chapters 13 and 14 on
Object-Oriented Programming.
I was fortunate to work with Beth Lang Golub, editor and president of Prospect Press, who was flexible
and supportive of my goal to offer a good quality programming textbook at a reasonable price. Special
thanks go to Susan Hegedus, Kathy Bond Borie and Rachel Paul for their painstaking attention to detail in
editing this book, and to Annie Clark for the cover design.
I wish to acknowledge the contributions of the following reviewers for their valuable guidance in
improving the presentation and contents of this book:
Janet Bailey, University of Arkansas at Little Rock
Wei Kian Chen, Champlain College
Clinton Daniel, University of South Florida
Silvana Faja, University of Central Missouri
Joni L. Jones, University of South Florida
David Pumphrey, Colorado Mesa University
Manonita M. Ratwatte, University of Oklahoma (Retired)
Theadora Ross, University of Arkansas at Little Rock
David M. Weber, Northern Arizona University
Thanks are also due to the instructors who provided valuable feedback on the first edition of this book
through user surveys:
Janet Bailey, University of Arkansas, Little Rock
Jeff Dickson, Oregon Institute of Technology
Ruth Lamprecht, Virginia Union University
Panos Linos, Butler University
Ziping Liu, Southeast Missouri State University
Robert Pilgrim, Murray State University
Kris Rosenberg, Oregon Institute of Technology
Doug Titus, University of North Florida

About the Author


Dr. George Philip is Professor Emeritus of Information Systems at the College of Business, The
University of Wisconsin–Oshkosh. He has more than twenty-five years of teaching and consulting
experience in the information systems field, including computer programming in multiple languages. He
also served as chair of the Information Systems Team, and director of the M.S. in Information Systems
program. He has published numerous articles in this field.
Chapter 1

Introduction to Visual Studio and Programming

Welcome to programming in C# language. In this chapter, you will learn to develop simple programs in
the Visual Studio development environment, and to work with different types of data.
Learning Objectives
After studying this chapter, you should be able to:
 Identify the inputs, processes and outputs of a software system.
 Describe the steps involved in developing a computer program.
 Describe the terms: syntax, logic and runtime errors, machine language, low-level language, high-
level language, compiler and interpreter.
 Develop a simple form in Visual Studio to accept user input, do calculations and display
formatted output.
 Work with Label, TextBox, Button, ListBox and MessageBox.
 Develop simple programs that use constants, variables and expressions.
 Use try-catch method to catch errors.

Topics

1.1 Introduction to Programming 1.8 Working with Variables


1.2 Introduction to Visual Studio 1.9 Doing Calculations
1.3 Visual Studio Environment 1.10 Formatting and Displaying Output in a Label
1.4 Adding Controls to a Form 1.11 Additional Concepts: Constants, Scope of
1.5 The Code Editor Window Variables and ListBox
1.6 Introductory Programming Concepts 1.12 Exception Handling: Catching Errors
1.7 Data Types

1.1 Introduction to Programming


Programming is the process of developing computer programs. If a computer program seems like a
mystery to you, it is just a set of instructions telling the computer how to do a task, like looking up the
price of an item or finding the Chinese restaurants in a city.
Unfortunately, computers cannot understand normal English. So, programs have to be written using
special commands and statements according to strict rules. A key aspect of programming is breaking
down what you want the computer to do, into detailed instructions. Like the directions that a GPS gives
you to get to a place, the instructions in a program need to be precise.

Fundamentals of C# Programming for


Information Systems
2 1.1 Introduction to Programming

Typically, a program uses one or more data items to produce some results. For example, a program that
processes an order might use the item number and order quantity to compute the subtotal, sales tax and
total cost, as represented in Figure 1-1.

Figure 1-1: Inputs, process and outputs of a program

Subtotal
Item# Process
Sales tax
Quantity Order
Total cost

The program, represented by the block “Process Order,” may include multiple subtasks like look up the
unit price, check inventory and compute results.
The data that are used by a program are called the input to the program, and the results produced are
called the output of the program. In addition to processing input data to produce the output, a program
might write data to and read data from storage devices like a flash drive or a hard drive, as represented in
Figure 1-2.

Figure 1-2: A general representation of a software system

How Do I Go About Developing a Program?


To understand the process of developing a program, let’s use a simplified order-processing system as an
example. To develop good programs and do so efficiently, follow these steps:
1. Define the purpose, and identify the input, process and output of the program.
2. Design and develop the graphical user interface (GUI).
3. Identify the components and logic of the program.
4. Design and develop files/databases, if any.
5. Write and test the code.
Let’s look at these steps in more detail.

1. Define the purpose, and identify input/process/output


Before you can write the program, you need to lay some groundwork. In this step, you identify what the
user wants the program to do, including the input, process and output of the program.
Depending on the size and complexity of the program, this could involve extensive analysis of the
requirements, including interviews with users; examination of current forms, reports and transactions; and
identifying processes like checking inventory and looking up price in an order.

Fundamentals of C# Programming for


Information Systems
Chapter 1: Introduction to Visual Studio and Programming 3

Here is an example of a simplified statement of the purpose of the order processing program:
Purpose: Compute and display the subtotal, sales tax and total cost for an order
The output of the program often follows from the purpose. For this example, the output would be
Output: subtotal, sales tax, total cost
The process specifies not only what the program should do (e.g., compute total cost) but also how it
should be done (e.g., how to compute total cost), as follows:
Process: (What?) Look up unit price, look up sales tax rate,
compute subtotal, sales tax and total cost
(How?) subtotal: unit price * order quantity
sales tax: subtotal * sales tax rate
total cost: subtotal + sales tax

Specifying the process also would include identifying the sources of data, like the product file to get the
unit price and sales tax file to get the sales tax rate.
The input specifies the data items that are needed to carry out the process to produce the output. The
input for this order-processing system would be
Input: item number, order quantity
Note that unit price and sales tax rate are not included in the input because the program looks them up. A
real-world system would be a lot more complex. Typically, the process would include additional subtasks
like handling orders when inventory is insufficient, and output may include various reports. In such
systems, graphical methods like Data Flow Diagrams and UML diagrams are used to represent the
processes and the data accessed by them.

2. Design and develop the graphical user interface (GUI)


After identifying the input, process and output of a program, you design and create the user interface—
that is, how the user would interact with the program, and how the program would communicate with the
user. This is the fun part where you bring in your creativity.
Typically, you use forms to interact with the program. As you will learn in the next section, forms have
various types of objects, called controls, such as Button, TextBox and Label. In this step, you identify the
type of controls to be used, specify their names and captions as appropriate, and design the layout. Figure
1-3 shows an example of the GUI for a simplified order-processing system where the user doesn’t provide
the unit price and sales tax rate.

Fundamentals of C# Programming for


Information Systems
4 1.1 Introduction to Programming

Figure 1-3: GUI for an order-processing system

3. Identify the components and logic of the program


This step identifies the major subtasks of the program. For example, in order to process an order, the
program needs to do the following subtasks:
Get Item# and quantity
Look up unit price and tax rate
Compute subtotal, sales tax and total cost
Display subtotal, sales tax and total cost

Again, a real-world program may have to do additional subtasks, like checking the inventory to make sure
there is sufficient quantity on stock.
For relatively simpler programs, after identifying the subtasks, you may go directly to writing the
program for each subtask. However, for tasks involving more complex logic, it might help to develop an
outline of the logic of performing the subtasks. The representation of the logic of a program in plain
English is called pseudo code. You also may represent the logic graphically using a flowchart, as
discussed in Chapter 3.

4. Design and develop files/databases


If data is read from or written to files and/or databases, these are designed and developed prior to writing
the program. Depending on the application, this step may have to be done in parallel with previous steps.

5. Write and test the code


The final step is to write and test the code. You can program in a variety of languages. C#, Java, Visual
Basic, Python and PHP are among the popular languages. You will use C#, which is a popular language
for developing desktop and web applications.
Programing may involve iteratively developing an application by going through the above steps multiple
times.

Syntax, Logic and Runtime Errors


The programming statements you write have to follow strict rules of the language, called the syntax. The
program wouldn’t compile if it had any syntax error, like a missing semicolon at the end of a statement
or a misspelled key word. Compiling is the process of translating the program you write, called the

Fundamentals of C# Programming for


Information Systems
Chapter 1: Introduction to Visual Studio and Programming 5

source code, to another language before running a program, as described in the next section. So, your
first task is to make sure that there are no syntax errors. The good news is that Visual Studio provides a
lot of help in identifying syntax errors.
After the syntax errors are eliminated, the program may run. But, it’s still too early to celebrate because
the results could be incorrect due to errors in the program logic, just like you can write a grammatically
correct sentence that doesn’t convey the intended message. Errors that cause a program to produce
incorrect or unintended results are called logic errors. A tax-filing software using the wrong tax rate and
a billing software overcharging a customer are examples of logic errors.
There are errors other than logic errors that can occur at runtime. These are called runtime errors.
Runtime errors cause the program to crash (unless the program catches and handles such errors) because
the program asks the computer to do something it is unable to do, like accessing a file with an invalid path
or dividing a number by zero.
The process of identifying errors (bugs) is called debugging. Testing programs to identify and eliminate
errors is an extremely important part of developing software.

Review Questions
1.1 Consider Google as a software system. What would be the input, process and output for Google?
1.2 Consider a software system that enrolls students into classes. Identify some key inputs that the
system needs every time a student enrolls in a class, and the subtasks (process) that need to be
performed. What are some outputs the system should produce for students and instructors?
1.3 List the major steps in developing a program.
1.4 Incorrect punctuation in a program is an example of what type of error?
1.5 A payroll program uses the wrong formula to compute overtime pay. What type of error is it?
1.6 True or false: A program that doesn’t have any syntax errors should produce the correct results.

1.2 Introduction to Visual Studio


In this section, you will learn how to use Visual Studio (VS) to create the user interface and write C#
programs. Visual Studio is an integrated development environment (IDE) for developing applications in a
variety of languages, including C#, Visual Basic, C++, Python and HTML/JavaScript. VS supports
development of desktop and web applications for Windows, Android and iOS. A major strength of Visual
Studio is that it provides a user-friendly environment for developing applications.

Installing Visual Studio


You may download Visual Studio Community 2017 from the following website:
https://www.visualstudio.com/downloads/
To install Visual Studio, open the downloaded vs_community.exe file. The installation software will
guide you through the process. The first time you start Visual Studio, you will be asked to choose the
Development Settings and a Color Theme. Choose Visual C# for settings. You may change these settings
later, as described in Tutorial 1.

Fundamentals of C# Programming for


Information Systems
6 1.2 Introduction to Visual Studio

Components of Visual Studio


Though you have the choice to write programs in a variety of languages, the CPU can understand only
Machine Language, which is extremely difficult for humans to understand. Machine Language requires
detailed instructions that consist of patterns of bits (0 and 1), like 10001010, and are dependent on the
machine (the specific type of computer). Because of the need to write detailed machine-dependent
instructions, Machine Language is called a low-level language.
Except in special cases, programs are written in high-level languages, like C#, which require fewer
statements, are less dependent on the hardware and are easier to understand because they use words rather
than patterns of bits.
Programs written in high-level languages are translated to Machine Language before they are run.
Different languages use different methods to translate and run programs. Many languages use a special
software called a compiler to translate the source code to Machine Language. The compiler typically
produces a separate executable Machine Language program that can be run any number of times without
having to compile every time it is run.
Some programming languages use an interpreter that translates each statement to Machine Language
and runs it without producing an executable program. So, every time the program is run, it needs to be
translated to Machine Language.
Visual Studio uses a compiler, but it translates the source code to an intermediate language, which is
translated to Machine Language and run using another software, as described later in this section. Thus,
Visual Studio translates your statements to Machine Language in two steps:
First, a compiler converts the source code into a language called Microsoft Intermediate Language (IL).
The compiled code, along with references to prebuilt programs (called classes), is stored in an executable
file called Microsoft Intermediate Language (IL) Assembly. Such files have the extension .exe or .dll.
Next, another software called Common Language Runtime (CLR) translates the assemblies from
Intermediate Language to Machine Language and executes the programs. The process of translating and
running the source code may be represented as follows:

The products that support developing and running programs within the Visual Studio family include the
following:
1. An Integrated Development Environment (IDE)
An IDE provides an environment to develop programs, which includes code editors for Visual
C#, Visual Basic, Visual J#, Visual C++, HTML and XML, and designers for Windows forms
and web forms.
In Visual Studio, a software application typically is organized into Projects that may contain one
or more forms.
Forms provide the user interface that allows users to input data for the program, to interact with
the program and to display results.

2. A compiler that translates the source code into Microsoft Intermediate Language (MSIL)

Fundamentals of C# Programming for


Information Systems
Chapter 1: Introduction to Visual Studio and Programming 7

3. .Net Framework, which includes


a. the Common Language Runtime (CLR) that translates the assemblies from Intermediate
Language to Machine Language and executes the programs, and
b. .Net Framework Class Library that includes a large number of prebuilt programs called
classes.

Running a program, as described earlier, consists of (1) the compiler translating the source code (the
project) into Microsoft Intermediate Language Assembly and (2) the Common Language Runtime
translating the assemblies from Intermediate Language to Machine Language and executing the program
to produce the output. Next, we will look at how to work with Visual Studio to develop C# programs.

Review Questions
1.7 What is the only programming language that the CPU can understand?
1.8 What is a compiler?
1.9 What is an interpreter?
1.10 What is Microsoft Intermediate Language Assembly?
1.11 What is the function of Common Language Runtime in Visual Studio?

Creating an Application in Visual Studio


To become familiar with the Visual Studio environment, let’s create an application for an ice cream
parlor, consisting of a simple Windows form to compute and display the cost for an order of ice cream.
We will follow the five steps identified earlier to develop it:

1. Define the purpose


Purpose: Compute and display the total cost for an order of ice cream
Input: Unit price, number of scoops
Process: Compute total cost
Total cost: unit price * number of scoops
Output: Total cost

2. Design and develop the Graphical User Interface (GUI)

Figure 1-4 presents the design of the form that shows the user interface to let the user enter the number of
scoops and unit price to display the cost. You will create the form in Tutorial 1.

Fundamentals of C# Programming for


Information Systems
8 1.2 Introduction to Visual Studio

Figure 1-4: Windows form to compute ice cream cost

3. Identify the components and logic of the program


The major subtasks include
Get number of scoops and unit price
Compute cost
Display cost

4. Design and develop files/databases


This application doesn’t involve the use of files or databases.

5. Write and test the code


To understand the process of developing the entire application, including the code, let’s create the form
presented in step 2 and write the code for the tasks identified in step 3.

Creating a Windows Form


In Visual Studio, forms are created within a Project. Typically, all forms within a Project relate to a
common task. Creating a project also creates a Solution, which is a container for one or more projects.
Each project we discuss in this book is in a separate solution that has the same name as the project.
Tutorial 1 creates the project and the form to compute the cost of an order of ice cream.

Fundamentals of C# Programming for


Information Systems
Chapter 1: Introduction to Visual Studio and Programming 9

Tutorial 1: Creating a Form: Ice Cream Cost


Step 1-1: Open Visual Studio Community 2017. You will see the start page, shown in Figure 1-5.

Figure 1-5: Visual Studio Start Page

First, you will change some settings.

Changing default settings in Visual Studio


Step 1-2: Change the default folder to save your projects:
Select Tools, Options. Expand Projects and Solutions and select Location.
For Projects Location, select a folder (e.g., your flash drive) where you will save your projects.
Step 1-3: Change the setting to automatically save projects when they are created:
Select General from Projects and Solutions.
Make sure that the CheckBox for Save new projects when created is checked. Click OK.

You may change the color theme by selecting Environment, General from the Options window.
Similarly, you may reset your settings by selecting Tools, Import and Export Settings, Reset all
Settings.
Close Options window.

Fundamentals of C# Programming for


Information Systems
10 Tutorial 1: Creating a Form: Ice Cream Cost

Creating a new project


Step 1-4: Create a new project:
Click Create New Project on the Start page.
You will see the New Project window displayed in Figure 1-6.

Figure 1-6: New Project window

Select Visual C# from Templates, Other Languages. For the type of application, select Windows
Forms Application, as shown in Figure 1-6.
For Name, enter Ch1_IntroProgramming.
Select the Location, if different from the default folder.
Leave the CheckBox for Create directory for solution unchecked so that both the Project and the
Solution will be created in the same folder. (If there are multiple Projects within a Solution, it
would be better to have separate directories for the Solution and Projects.) Note that the default
name for the Solution is the same as that of the Project.) Click OK.
The Visual Studio development environment appears, as shown in Figure 1-7.

Fundamentals of C# Programming for


Information Systems
Another Random Document on
Scribd Without Any Related Topics
with unbelievers. And, as wicked men's punishment is aggravated by
their being condemned to the fire prepared for the devil and his
angels; so the punishment of ordinary ungodly persons, is
aggravated by this, that their portion shall be with hypocrites and
unbelievers. How oft find you the Lamb of God himself denouncing
his thundering woes against the hypocritical scribes and Pharisees!
How oft doth he inculcate to his disciples, "Be not as the hypocrites,"
Matt. vi. 2, 5, 16. And no wonder if hypocrites be hateful to God,
when they and their services are lifeless images, and have nothing
but the name and outside of christianity, and some antique dress to
set them off, and human ornaments of wit and parts; as a corpse is
more drest with flowers than the living, as needing those ceremonies
for want of life to keep them sweet: and a carrion is not amiable to
God. And the hypocrite puts a scorn on God; as if he thought that
God were like the heathen's idols, that have eyes and see not, and
could not discern the secret dissemblings of his heart; or as if he
were like fools and children that are pleased with fair words and little
toys. God must needs hate such abuse as this.
Direct. XX. Come into the light, that your hearts and lives may be
thoroughly known to you. Love the most searching, faithful ministry
and books; and be thankful to reprovers and plain-dealing friends.
Darkness is it that cherisheth deceit: it is the office of the light to
manifest. Justly do those wretches perish in their hypocrisy, who will
not endure the light which would undeceive them; but fly from a
plain and powerful ministry, and hate plain reproof, and set
themselves by excuses and cavils to defend their own deceit.[154]
Direct. XXI. Be very diligent in the examining of your hearts and all
your actions by the word of God, and call yourselves often to a strict
account. Deceit and guilt will not endure strict examination. The
word of God is quick and powerful, discovering the thoughts and
imaginations of the heart. There is no hypocrite but might be
delivered from his own deceits, if by the assistance of an able guide,
he would faithfully go on in the work of self-trying, without partiality
or sloth.
Direct. XXII. Live continually as one that is going to be judged at the
bar of God, where all hypocrisy will be opened and shamed, and
hypocrites condemned by the all-knowing God. One thought of our
appearing before the Lord, and of the day of his impartial judgment,
one would think should make men walk as in the light, and teach
them to understand, that the sun is not eclipsed as often as they
wink, nor is it night because they draw the curtains. What a shame
will it be to have all your dissimulation laid open before all the world!
Luke xii. 1-3, "Beware of the leaven of the Pharisees, which is
hypocrisy: for there is nothing covered, which shall not be revealed;
neither hid, that shall not be known. Therefore whatever ye have
spoken in darkness shall be heard in the light; and that which ye
have spoken in the ear in closets, shall be proclaimed on the house-
tops."
Direct. XXIII. Think not that you avoid hypocrisy by changing the
expressions of it; but see that you run not into a more subtle kind,
while you avoid a grosser. There is no outward way of worshipping
God, nor any opinion in religion, so sound, but a hypocrite can make
a cloak of it. You see an ignorant, ridiculous hypocrite, such as
Bishop Hall describeth in his character, that can pray up to a pillar,
when his heart knoweth not what his tongue is doing; that babbleth
over a few words to God while he is dressing or washing him, and
talking between to the standers-by; who offereth to God the
sacrifice of a fool, and knoweth not that he doth evil, Eccles. v. 2;
that serveth God with toys and antic gestures, and saying over
certain words which were never acquainted with the feeling of his
heart, nor scarce with his understanding. And to avoid his hypocrisy,
perhaps, you can merrily deride him, and make a formal popish
hypocrite the subject of your jests; and you can yourselves, with
good understanding, pour out yourselves many hours together in
orderly and meet expressions of prayer: but remember that many a
hypocrite maketh himself a cloak of as good stuff as this; and that
as pride hath more advantage to work upon your greater knowledge
and better parts, so hypocrisy is but the offspring of pride. All this,
without a heart entirely devoted unto God, is but a carcass better
dressed; as the rich have more curious monuments than the poor.
There is no outside thing, in which a hypocrite may not seem
excellent.
Direct. XXIV. Be true to conscience, and hearken diligently to all it
saith, and be often treating with it, and daily conversant and well
acquainted with it.[155] Hypocrites bear little reverence to their
consciences: they make so often and so grossly bold with them, that
conscience is deposed from its office at the present, and silenced by
them, lest it should gall them by preaching to them those hard
sayings which they cannot bear: and perhaps at last it is seared or
bribed to take part with sin. But usually a hypocrite hath a secret
judge within him which condemneth him. Take heed how you use
your conscience, as you love your peace and happiness. Next Christ,
it must be your best friend, or your greatest enemy: palliate it how
you will at present, if you wound it, it will smart at last. And it is
easier to bear poverty, or shame, or torment, than to bear its
wounds, Prov. xviii. 14. 1. Mark the very principles and former
judgment of your consciences; and if they are changed, know what
changed them. 2. Hearken to all the secret counsel and reproofs of
conscience, especially when it speaketh oft and terribly; turn it not
off without a hearing; yea, know the reason of its very scruples and
doubts. 3. When it is sick and disquieted, know what the matter is,
Psal. liii. 5, and vomit up the matter that justly disquiets it, whatever
it cost you; and be sure you go to the bottom, and do not leave the
root behind. 4. Open your consciences to some able, trusty guide
when it is necessary, though it cost you shame. An over-tender
avoiding of such shame is the hypocrite's sin and folly. Counsel is
safe in matters of such importance. 5. Prefer conscience before all
men, how great soever: none is above it but God. It is God's
messenger, when it is conscience indeed: remember what it saith to
you, and from whom, and for what end. Let friends, and neighbours,
and company, and business, and profit, and sports, and honour
stand by, and all give place whilst conscience speaketh; for it will be
a better friend to you than any of these, if you use it as a friend. It
would have been better to Judas than his thirty pieces were. 6. Yet
see that it be well informed, and see its commission, for it is not
above God; nor is it masterless or lawless. 7. Converse not with it
only in a crowd, but in secret, Psal. iv. 4. 8. Keep it awake; and keep
it among awakening means and company: it will much sooner fall
asleep in an ale-house, or a play-house, or among the foolish and
profane, than at a lively sermon, or prayers, or reverent discourse of
God. If I could but get conscience awakened to perform its office,
and preach over all this that I have said in secret, it would ferret the
hypocrite out of his self-deceit. Go, conscience, and search that
deceitful heart, and speak to it in the name of God: ask that
hypocrite whether conversion ever made him a new creature, and
whether his soul and all that he hath be entirely devoted unto God?
and whether his hopes and treasures be laid up in heaven, and his
heart be there? and whether he subject all his worldly interest to the
will of God, and the interest of his soul? and whether his greatest
work be about his heart, and to approve himself to God? and
whether he make an impartial, diligent inquiry after the truth, with a
desire to receive it at the dearest rates? Tell him that a proud self-
flattery may now make him justify or extenuate his sins, and take his
formalities, and lip-service, and abuse of God for true devotion, and
hate every man that would detect his hypocrisy, and convert him by
bringing in the light; but a light will shortly appear to his soul, which
he shall not resist. And then let him stand to his justification if he
can; and let him then make it good that he gave up himself in
sincerity, simplicity, and self-denial, to his God.
Direct. XXV. Remember that hypocrisy lieth much in doubling, and in
a dividing heart and life: see therefore that you serve God in
singleness of heart, or simplicity and integrity, as being his alone.
Think not of serving God and mammon: a deep reserve at the heart
for the world, while they seem to give up themselves in covenant to
God, is the grand character of a hypocrite. Live as those that have
one Lord and one Master, that all power stoopeth to; and one end or
scope, to which all other are but means; and one work of absolute
necessity to do; and one kingdom to seek first, and with greatest
care and diligence to make sure of; and that have your hearts and
faces still one way; and that agree with yourselves in what you
think, and say, and do.[156] A double heart and a double tongue is
the fashion of the hypocrite, Psal. xii. 2; 1 Tim. iii. 8. He hath a heart
for the world, and pride, and lust, which must seem sometimes to be
lifted up to ask forgiveness, that he may sin with quietness and hope
of salvation: you would not think when you see him drop his beads,
or lift up his hands and eyes, and seem devoutly to say his prayers,
how lately he came from a tavern, or a whore, or a lie, or from
scorning at serious godliness. As Bishop Hall saith, he seemeth to
serve that God at church on holy-days, whom he neglecteth at
home; and boweth at the name of Jesus, and sweareth profanely by
the name of God. Remember that there is but one God, one heaven
for us, one happiness, and one way;[157] and this one is of such
moment, as calls for all the intention and attention of our souls, and
is enough to satisfy us, and should be enough to call us off from all
that would divert us. A divided heart is a false and self-deceiving
heart. Are there two Gods? or is Christ divided?[158] While you grasp
at both (God and the world) you will certainly lose one, and it is like
you will lose both. To have two Gods, two rules, two heavens, is to
have no God, no true rule, no heaven or happiness at all. Halt not
therefore between two opinions: if God be God, obey him and love
him; if heaven be heaven, be sure it be first sought. But if thy belly
be thy god, and the world be thy heaven, then serve and seek them,
and make thy best of them.
Direct. XXVI. Take heed of all that fleshly policy or craft, and worldly
wisdom, which are contrary to the wisdom of the word of God, and
would draw thee from the plain and open-heartedness which godly
sincerity requireth. Let that which was Paul's rejoicing be yours,
"that in simplicity and godly sincerity, not in fleshly wisdom, you
have had your conversation in the world," 2 Cor. i. 12. Christianity
renounceth not wisdom and honest self-preservation; but yet it
maketh men plain-hearted, and haters of crafty, fraudulent minds.
What is the famous hypocritical religion superadded to christianity
and called popery, but that which Paul feared in his godly jealousy
for the Corinthians, "lest as the serpent beguiled Eve by his subtilty,
so their minds should be corrupted from the simplicity that is in
Christ," 2 Cor. xi. 1-3. A forsaking the christian simplicity of doctrine,
discipline, worship, and conversation, is the hypocrisy of religion,
and of life. Equivocating and dishonest shifts and hiding, beseem
those that have an ill cause, or an ill conscience, or an ill master
whom they dare not trust; and not those that have so good a cause
and God as christians have.
Direct. XXVII. Remember how much of sincerity consisteth in
seriousness, and how much of hypocrisy consisteth in seeming, and
dreaming, and trifling in the things of God and our salvation: see
therefore that you keep your souls awake, in a sensible and serious
frame.[159] Read over the fifty considerations, which, in the third
part of my "Saints' Rest," I have given to convince you of the
necessity of being serious. See that there be as much in your faith
as in your creed, and as much in your hearts and lives as in your
belief. Remember that seeming and dreaming will not mortify deep-
rooted sins, nor conquer strong and subtle enemies, nor make you
acceptable to God, nor save your souls from his revenging justice.
Remember what a mad kind of profaneness it is to jest and trifle
about heaven and hell, and to dally with the great and dreadful God.
"Seeing all these things shall be dissolved, what manner of persons
ought you to be in all holy conversation and godliness?" 2 Pet. iii. 11.
You pray for an obedience answering the pattern of the heavenly
society, when you say, "Thy will be done on earth as it is in heaven;"
and will you be such hypocrites as to pray, that you may imitate
saints and angels in the purity and obedience of your hearts and
lives, and when you have done, take up with shows, and seemings,
and saying a few words, and a lifeless image of that holiness which
you never had; yea, and perhaps deride and persecute in others the
very thing which you daily pray for. O horrible abuse of the all-seeing
God! Do you no more believe or fear his justice? When the apostle
saith, Gal. vi. 7, "Be not deceived, God is not mocked;" he
intimateth, that hypocrites go about to put a scorn on God by a
mock religion, though it is not he, but themselves, that will prove
mocked in the end. They offer God a deaf nut, or an empty shell or
cask, for a sacrifice. An hypocrite differeth from a true christian, as a
fencer from a soldier; he playeth his part very formally upon a stage
with much applause; but you may perceive that he is not in good
sadness, by his trifling and formality, and never killing any of his
sins. Would men show no more of the great, everlasting matters of
their own professed belief, in any seriousness of affection or
endeavour than most men do, if they were not hypocrites? Would
they hate and scorn men for doing but that (and part of that) which
they pray and profess to do themselves, if they were not hypocrites?
Woe to the world, because of hypocrisy! Woe to the carnal members
of the church! Woe to idol shepherds, and the seeming, nominal,
lifeless christians, of what sect soever! for God will not be mocked.
They are christians, but it is with a mock christianity, while their
souls are strange to the true esteem and use of Christ. They are
believers, but with a mock belief, described James ii. They believe
God should be loved above all, but they love him not. They believe
that holiness is better than all the pleasures of sin; yet they choose
it not, but hate it.[160] They are religious, with a seeming vain
religion, which will not so much as humble them, nor bridle their
tongues, James i. 26. They are wise, with a mock wisdom; they are
wise enough to prove their sins to be all lawful, or but venial sins:
and wise enough to cast away the medicine that would heal them;
and to confute the physician, and to answer the learnedst preacher
of them all, and to scape salvation, and to secure themselves a place
in hell, and keep themselves ignorant of it till they are there. They
are converted, but with a mock conversion; which leaveth them as
carnal, and proud, and worldly as before; being born of water but
not of the Spirit, and being sensual still, John iii. 5, 6; Jude 19. They
repent, but with a mock repentance; they repent, but they will not
leave their sin, nor confess and bewail it, but hate reproof, and
excuse their sin. They are honest, but with a mock honesty; though
they swear, and curse, and rail, and slander, and backbite, and scorn
at piety itself, yet they mean well, and have honest hearts: though
they receive not the word with deep-rooting in their hearts, but are
abominable and disobedient, and to every good work reprobate,
they are honest for all that, Luke viii. 15; Tit. i. 16. They love God
above all, though they love not to think or speak of him seriously,
but hate his holiness and justice, his word and holy ways and
servants, and are such as the Scripture calleth "haters of God;" and
keep not his commandments, nor live to his glory.[161] They love the
servants of God, but they care not if the world were rid of them all;
and take them to be but a company of self-conceited, troublesome
fellows, and as very hypocrites as themselves; and the poor
christians that are cruelly used by them, think they are neither in
good sadness nor in jest, when they profess to love the worshippers
of God. They love not their money, nor lands, nor lusts, with such a
kind of love, I am sure. They have also always good desires; but
they are such mock desires as those in James ii. 15, that wished the
poor were fed, and clothed, and warmed, but gave them nothing
towards it: and such good desires as the sluggard hath, that lieth in
bed and wisheth that all his work were done, Prov. xxi. 25. "The
desire of the sluggard killeth him, because his hands refuse to
labour." They pray, but with mock prayers; you would little think that
they are speaking to the most holy God, for no less than the saving
of their souls, when they are more serious in their very games and
sports. They pray for grace, but they cannot abide it; they pray for
holiness, but they are resolved they will have none of it; they pray
against their sin, but no entreaty can persuade them from it. They
would have a mock ministry, a mock discipline, a mock church, a
mock sacrament, as they make a mock profession, and give God but
a mock obedience; as I might show you through all the particulars,
but for being tedious. And all this, because they have but a mock
faith: they believe not that God is in good earnest with them in his
commands, and threatenings, and foretelling of his judgments; as
Lot to his sons-in-law, Gen. xix. 14, "He seemeth to them as one
that mocked," and therefore they serve him as those that would
mock him. O wretched hypocrites! is this agreeable to your holy
profession? You call yourselves christians, and profess to believe the
doctrine of Christ: is this agreeable to christianity, to your creed, to
the ten commandments, to the Lord's prayer, and to the rest of the
word of God? Had you none but the holy, jealous God to make a
mock of? Had you nothing less than religion, and matters of
salvation and damnation, to play with? Do you serve God as if he
were a child, or an idol, or a man of straw; that either knoweth not
your hearts, or is pleased with toys, and compliments, and shows,
and saying over certain words, or acting a part before him as on a
stage?[162] Do you know what you offer, and to whom? His power is
omnipotency; his glory is ten thousand-fold above that of the sun;
his wisdom is infinite; millions of angels adore him continually; he is
thy King and Judge; he abhorreth hypocrites. If thou didst but see
one glimpse of his glory, or the meanest of his angels, the sight
would awake thee from thy dreaming and dallying, and frighten thee
from thy canting and trifling into a serious regard of God and thy
everlasting state. Mal. i. 8, "Offer this now to thy governor: will he
be pleased with thee, or accept thy person, saith the Lord of hosts?"
If your servants set before you upon your table the feathers instead
of the fowl, and the hair and wool instead of the flesh, and the
scales instead of the fish, would you not think they rather mocked
than served you? How dear have some paid even in this life for
mocking God, let the case of Aaron's sons, Lev. x. 1-3, and of
Ananias and Sapphira, Acts v. inform you: if with the fig-tree, Matt.
xxi. 19, you offer God leaves only instead of fruit, you are nigh unto
cursing, and your end is to be burned. Do you not read what he
saith to the church of Laodicea, Rev. iii. 15, 16, "I would thou wert
cold or hot; because thou art lukewarm, and neither cold nor hot, I
will spue thee out of my mouth:" that is, either be an open infidel, or
a holy, downright, zealous christian: but because thou callest thyself
a christian, and hast not the life or zeal of a christian, but coverest
thy wickedness and carnality with that holy name, I will cast thee
away as an abominable vomit. It would make the heart of a believer
ache to think of the hypocrisy of most that usurp the name of
christians, and how cruelly they mock themselves. What a glory is
offered them, and they lose it by their dallying! What a price is in
their hands, what mercy is offered them, and they lose it by their
dallying! What danger is before them, and they will fall into it by
their dallying! Doth not the weight of your salvation forbid this
trifling? You might better set the town on fire, and make a jest of it,
than jest your souls into the fire of hell. Then you will find that hell is
no jesting matter. If you mock yourselves out of your salvation,
where are you then? If you play with time, and means, and mercy
till they are gone, you are undone for ever. O dally not till you are
past remedy. Alas, poor dreaming trifling hypocrites! Is time so
sweet, and life so short, and death so sure and near, and God so
holy, just, and terrible, and heaven so glorious, and hell so hot, and
both everlasting, and yet will you not be in earnest about your work?
Up and be doing, as you are men! and as ever you care what
becomes of you for ever! Depart from iniquity, if you will name the
name of Christ, 2 Tim. ii. 19. Let not a cheating world delude you for
a moment, and have the kernel, the heart, while God hath but the
empty shell. A mock religion will but keep up a mock hope, a mock
peace, and a mock joy and comfort, till Satan have done his work,
and be ready to unhood you and open your eyes. Job viii. 13, "So
are the paths of all that forget God; and the hypocrite's hope shall
perish." Job xxvii. 8, 9, "For what is the hope of the hypocrite,
though he hath gained, when God taketh away his soul? Will God
hear his cry when trouble cometh upon him?" Job xx. 4-7, "Knowest
thou not this of old, that the triumphing of the wicked is short, and
the joy of the hypocrite but for a moment? Though his excellency
mount up to the heavens, and his head reach unto the clouds, yet
he shall perish for ever like his own dung: they which have seen him
shall say, Where is he?" Away then with hypocritical formality and
dalliance, and be serious and sincere for thy soul, and with thy God.

PART IV.

Directions against inordinate Man-pleasing; or that overvaluing the


Favour and Censure of Man, which is the fruit of Pride, and a great cause
of Hypocrisy; or, Directions against Idolizing Man.
As in other cases, so in this, iniquity consisteth not simply in the
heart's neglect of God, but in the preferring of some competitor, and
prevalence of some object which standeth up for an opposite
interest.[163] And so the obeying man before God and against him,
and the valuing the favour and approbation of man before or against
the approbation of God, and the fearing of man's censure or
displeasure more than God's, is an idolizing man, or setting him up
in the place of God. It turneth our chiefest observance, and care,
and labour, and pleasure, and grief into this human fleshly channel,
and maketh all that to be but human in our hearts and lives, which
(objectively) should be divine. Which is so great and dangerous a
sin, partaking of so much impiety, hypocrisy, and pride, as that it
deserveth a special place in my directions, and in all watchfulness
and consideration to escape it.
As all other creatures, so especially man, must be regarded and
valued only in a due subordination and subserviency to God. If they
be valued otherwise, they are made his enemies, and so are to be
hated,[164] and are made the principal engine of the ruin of such as
overvalue them. See what the Scripture saith of this sin: Isa. ii. 22,
"Cease ye from man, whose breath is in his nostrils: for wherein is
he to be accounted of?" Matt. xxiii. 9, "And call no man your father
upon the earth; for one is your Father which is in heaven."[165] Ver.
8, "And be not ye called Rabbi; for one is your Master, even Christ:
but he that is greatest among you shall be your servant." Jer. xx. 15,
"Cursed be the man that trusteth in man, and maketh flesh his arm."
Psal. cxviii. 6, 8, 9, "The Lord is on my side; I will not fear what man
can do unto me. It is better to trust in the Lord, than to put
confidence in man,—yea, in princes." Job xxxii. 21, 22, "Let me not
accept any man's person; neither let me give flattering titles unto
man: for I know not to give flattering titles; in so doing my Maker
would soon take me away." Job xxi. 4, "As for me, is my complaint
to man?" Gal. i. 10, "Do I seek to please men? for if I yet pleased
men, I should not be a servant of Christ." 1 Cor. iv. 3, "But with me
it is a very small thing to be judged of you, or of man's judgment."
Luke xiv. 26, "If a man come to me, and hate not his father, and
mother, and wife, and children, and brethren, and sisters, yea, and
his own life also, he cannot be my disciple." "Blessed are ye when
man shall revile you, and persecute you, and shall say all manner of
evil against you falsely for my sake. Rejoice, and be exceeding glad:
for great is your reward in heaven," Matt. v. 11, 12. "Not with eye-
service, as men-pleasers," Eph. vi. 6; Col. iii. 22. 1 Thess. ii. 4, "So
we speak, not as pleasing men but God, who trieth our hearts." Jude
16, "Having men's persons in admiration because of advantage."
[166] This is enough to show you what Scripture saith of this
inordinate man-pleasing, or respect to man: and now I shall proceed
to direct you to escape it.
Direct. I. Understand well wherein the nature of this sin consisteth,
that you may not run into the contrary extreme, but may know
which way to bend your opposition. I shall therefore first show you,
how far we may and must please men, and how far not.
1. Our parents, rulers, and superiors must be honoured, obeyed, and
pleased in all things which they require of us, in the several places of
authority which God hath given them over us; and this must be not
merely as to man, but as to the officers of God, from whom, and for
whom, (and not against him,) they have all their power, Rom. xiii.;
Exod. xx. 12; Titus iii. 1; 1 Pet. ii. 13; 2 Pet. ii. 10.
2. We must in charity, and condescension, and meekness of
behaviour, seek to please all men in order to their salvation. We
must so thirst for the conversion of sinners, that we must become all
things (lawful) to all men, that we may win them.[167] We must not
stand upon our terms, and keep at a distance from them, but
condescend to the lowest, and bear the infirmities of the weak; and
in things indifferent not take the course that pleaseth ourselves, but
that which, by pleasing him, may edify our weak brother. We must
forbear and forgive, and part with our right, and deny ourselves the
use of our christian liberty, were it as long as we live, if it be
necessary to the saving of our brethren's souls, by removing the
offence which hindereth them by prejudice. We must not seek our
own carnal ends, but the benefit of others, and do them all the good
we can.
3. As our neighbour is commanded to love us as himself, we are
bound by all lawful means to render ourselves amiable to him, that
we may help and facilitate this his love, as it is more necessary to
him than to us: for to help him in obeying so great a command must
needs be a great duty. And therefore if his very sin possess him with
prejudice against us, or cause him to distaste us for some indifferent
thing, we must, as far as we can lawfully, remove the cause of his
prejudice and dislike; though he that hateth us for obeying God,
must not be cured by our disobeying him. We are so far from being
obliged to displease men by surliness and morosity, that we are
bound to pleasing gentleness, and brotherly kindness, and to all that
carriage which is necessary to cure their sinful hatred or dislike.
4. We must not be self-conceited, and prefer a weak, unfurnished
judgment of our own, before the greater wisdom of another; but in
honour must prefer each other: and the ignorant must honour the
knowledge and parts of others that excel them, and not be stiff in
their own opinion, nor wise in their own eyes, nor undervalue
another man's reasons or judgment; but be glad to learn of any that
can teach them, in the humble acknowledgment of their own
insufficiency.
5. Especially we must reverence the judgment of our able, faithful
teachers, and not by pride set up our weaker judgment against
them, and resist the truth which they deliver to us from God. Neither
must we set light by the censures or admonitions of the lawful
pastors of the church:[168] when they are agreeable to the word and
judgment of God, they are very dreadful. As Tertullian saith, If any
so offend as to be banished from communion of prayer, and
assembly, and all holy commerce, it is a judgment foregoing the
great judgment to come. Yea, if the officers of Christ should wrong
you in their censures by passion or mistake, while they act in their
own charge about matters belonging to their cognisance and
judgment, you must respectfully and patiently bear the wrong, so as
not to dishonour and contemn the authority and office so abused.
6. If sober, godly persons, that are well acquainted with us, do
strongly suspect us to be faulty where we discern it not ourselves, it
should make us the more suspicious and fearful: and if judicious
persons fear you to be hypocrites, and no sound christians, by
observing your temper and course of life, it should make you search
with the greater fear, and not to disregard their judgment. And if
judicious persons, especially ministers, shall tell a poor, fearful,
doubting christian, that they verily think their state is safe, it may be
a great stay to them, and must not be slighted as nothing, though it
cannot give them a certainty of their case. Thus far man's judgment
must be valued.
7. A good name among men, which is the reputation of our integrity,
is not to be neglected as a thing of nought; for it is a mercy from
God for which we must be thankful, and it is a useful means to our
successful serving and honouring God. And the more eminent we
are, and the more the honour of God and religion is joined with
ours, or the good of men's souls dependeth on our reputation, the
more careful we should be of it; and it may be a duty sometimes to
vindicate it by the magistrate's justice, against a slander. Especially
preachers (whose success for the saving of their hearers depends
much on their good name) must not despise it.[169]
8. The censures of the most petulant, and the scorns of enemies,
are not to be made light of, as they are their sins, which we must
lament; nor as they may provoke us to a more diligent search, and
careful watchfulness over our ways. Thus far man's judgment is
regardable.
But, 1. We must know how frail, and erroneous, and unconstant a
thing man is; and therefore not be too high in our expectations from
man. We must suppose that men will mistake us, and wrong us, and
slander us, through ignorance, passion, prejudice, or self-interest.
And when this befalls us, we must not account it strange and
unexpected.
2. We must consider how far the enmity that is in lapsed man to
holiness, and the ignorance, prejudice, and passion of the ungodly,
will carry them to despise, and scorn, and slander all such as
seriously and zealously serve God, and cross them in their carnal
interest. And therefore, if for the sake of Christ and righteousness,
we are accounted as the scorn and offscouring of all things, and as
pestilent fellows, and movers of sedition among the people, and
such as are unworthy to live, and have all manner of evil spoken of
us falsely, it must not seem strange or unexpected to us, nor cast us
down, but we must bear it patiently, yea, and exceedingly rejoice in
hope of our reward in heaven.[170]
3. Considering what remnants of pride and self-conceitedness
remain in many that have true grace, and how many hypocrites are
in the church, whose religion consisteth in opinions and their several
modes of worship; we must expect to be reproached and abused by
such, as in opinions, and modes, and circumstances do differ from
us, and take us therefore as their adversaries. A great deal of
injustice, sometimes by slanders or reproach, and sometimes by
greater violence, must be expected, from contentious professors of
the same religion with ourselves: especially when the interest of
their faction or cause requireth it: and especially if we bring any
truth among them, which seemeth new to them, or crosseth the
opinions which are there in credit, or would be reformers of them in
any thing that is amiss.
4. No men must be pleased by sin, nor their favour preferred before
the pleasing of God. Man's favour as against God, is to be despised,
and their displeasure made light of. If doing our duty will displease
them, let them be displeased; we can but pity them.
5. We must place none of our happiness in the favour or approbation
of men, but account it as to ourselves to be a matter of no great
moment; neither worth any great care or endeavour to obtain it, or
grief for losing it. We must not only contemn it as compared to the
approbation and favour of God, but we must value it but as other
transitory things, in itself considered; estimating it as a means to
some higher end, the service of God, and our own or other men's
greater good: and further than it conduceth to some of these, it
must be almost indifferent to us what men think or say of us: and
the displeasure of all men, if unjust, must be reckoned with our light
afflictions.
6. One truth of God, and the smallest duty, must be preferred before
the pleasing and favour of all the men in the world. Though yet as a
means to the promoting of a greater truth or duty, the favour and
pleasing of men must be preferred before the uttering of a lesser
truth, or doing a lesser good at that time: because it is no duty then
to do it.
7. Our hearts are so selfish and deceitful, naturally, that when we
are very solicitous about our reputation, we must carefully watch
them lest self be intended, while God is pretended. And we must
take special care, that we be sure it be the honour of God, and
religion, and the good of souls, or some greater benefit than honour
itself, that we value our honour and reputation for.
8. Man's nature is so prone to go too far in valuing our esteem with
men, that we should more fear lest we err on that hand, than on the
other, in undervaluing it. And it is far safer to do too little than too
much, in the vindicating of our own reputation, whether by the
magistrate's justice, or by disputing, or any contentious means.
9. We must not wholly rest on the judgment of any, about the state
of our souls, nor take their judgment of us for infallible; but use their
help that we may know ourselves.
10. If ministers, or councils called general, do err and contradict the
word of God, we must do our best to discern it; and discerning it,
must desert their error rather than the truth of God. As Calvin, and
after him Paræus on 1 Cor. iv. 3, say, "We must give an account of
our doctrine to all men that require it, especially to ministers and
councils: but when a faithful pastor perceiveth himself oppressed
with unrighteous and perverse designs and factions, and that there
is no place for equity and truth, he ought to be careless of man's
esteem, and appeal to God, and fly to his tribunal. And if we see
ourselves condemned, our cause being unpleaded, and judgment
passed, our cause being unheard, let us lift up our minds to this
magnanimity, as despising men's judgment, to expect with boldness
the judgment of God;" and say with Paul, "With me it is a small
matter to be judged of you, or of man's judgment; I have one that
judgeth me, even the Lord."
11. God must be enough for a gracious soul, and we must know
"that in his favour is life," and his "loving-kindness is better than life
itself:" and this must be our care and labour, that "whether living or
dying we may be accepted of him:" and if we have his approbation it
must satisfy us, though all the world condemn us.[171] Therefore
having faithfully done our duty, we must leave the matter of our
reputation to God; who, if our ways please him, can make our
enemies to be at peace with us, or be harmless to us as if they were
no enemies. As we must quietly leave it to him what measure of
wealth we shall have, so also what measure of honour we shall
have. It is our duty to love and honour, but not to be beloved and
honoured.
12. The prophecy of our Saviour must be still believed, that the
"world will hate us;" and his example must be still before our eyes,
who submitted to be spit upon, and scorned and buffeted, and
slandered as a traitor or usurper of the crown, and "made himself of
no reputation," and "endured the cross," and "despised the shame;"
leaving us an example that we "should follow his steps, who did no
sin, neither was guile found in his mouth; who, when he was reviled,
reviled not again; when he suffered, he threatened not, but
committed all to him that judgeth righteously."[172] This is the usage
that must be the christian's expectation, and not to be well spoken
of by all, nor to have the applause and honour of the world.
13. It is not only the approbation of the ignorant and ungodly that
we must thus set light by; but even of the most learned and godly
themselves, so as to bear their censures as an easy burden, when
God is pleased this way to try us; and to be satisfied in God alone,
and the expectation of his final judgment.[173]
Direct. II. Remember that the favour and pleasing of man is one of
your snares, that would prevail against your pleasing God: therefore
watch against the danger of it, as you must do against other earthly
things.
Direct. III. Remember how silly a creature man is; and that his
favour can be no better than himself. The thoughts or words of a
mortal worm are matters of no considerable value to us.
Direct. IV. Remember that it is the judgment of God alone, that your
life or death for ever doth depend upon; and how little you are
concerned in the judgment of man. 1. An humbled soul, that hath
felt what it is to have displeased God, and what it is to be under his
curse, and what it is to be reconciled to him by the death and
intercession of Jesus Christ, is so taken up in seeking the favour of
God, and is so troubled with every fear of his displeasure, and is so
delighted with the sense of his love, as that he can scarce have
while to mind so small a matter as the favour or displeasure of a
man. God's favour is enough for him, and so precious to him, that if
he find that he hath this, so small a matter as the favour of a man
will scarce be missed by him.
2. God only is our supreme Judge, and our governors as officers
limited by him: but for others, if they will be usurpers, and set
themselves in the throne of God, and there let fly their censures
upon things and persons which concern them not, why should we
seem much concerned in it? If a beggar step up into a seat of
judicature, and there condemn one, and fine another, will you fear
him, or laugh at him? Who art thou that judgest another man's
servant? To his own master doth he stand or fall. Men may step up
into the throne of God, and there presume to judge others according
to their interests and passions: but God will quickly pull them down,
and teach them better to know their places. How like is the common
censure of the world, to the game of boys, that will hold an assize,
and make a judge, and try and condemn one another in sport! And
have we not a greater Judge to fear?
3. It is God only that passeth the final sentence, from whom there is
no appeal to any other: but from human judgment there lieth an
appeal to God.[174] Their judgment must be judged of by him.
Things shall not stand as now men censure them. Many a bad cause
is now judged good, through the multitude or greatness of those
that favour it: and many a good cause is now condemned. Many a
one is taken as a malefactor because he obeyeth God and doth his
duty. But all these things must be judged over again, by him that
hath denounced a "woe to them that call evil good and good evil,
that put darkness for light and light for darkness," Isa. v. 20. "He
that saith to the wicked, Thou art righteous, people shall curse him,
nations shall abhor him," Prov. xxiv. 24. It were ill with the best of
the servants of Christ, if the judgment of the world must stand, who
condemn them as fools, and hypocrites, and what they list: then the
devil's judgment would stand. But he is the wise man that God will
judge to be wise at last; and he only is the happy man that God calls
happy. The erring judgment of a creature is but like an ignorant
man's writing the names of several things upon an apothecary's
boxes; if he write the names of poisons upon some, and of antidotes
on others, when there are no such things within them, they are not
to be estimated according to those names.[175] How different are
the names that God and the world do put upon things and persons
now! And how few now approve of that which God approveth of, and
will justify at last! How many will God judge heterodox and wicked,
that men judged orthodox, and worthy of applause! And how many
will God judge orthodox and sincere, that were called heretics and
hypocrites by men! God will not verify every word against his
servants, which angry men, or contentious disputants, say against
them. The learning, or authority, or other advantages of the
contenders, may now bear down the reasons and reputations of
more wise and righteous men than they, which God will restore and
vindicate at last. The names of Luther, Zuinglius, Calvin, and many
other excellent servants of the Lord, are now made odious in the
writings and reports of papists, by their impudent lies; but God
judgeth otherwise, with more righteous judgment. Oh what
abundance of persons and causes will be justified at the dreadful
day of God, which the world condemned! And how many will be
there condemned, that were justified by the world! O blessed day!
most desirable to the just, most terrible to the wicked and every
hypocrite. How many things will then be set straight, that now are
crooked! and how many innocents and saints will then have a
resurrection of their murdered names, that were buried by the world
in a heap of lies, and their enemies never thought of their reviving!
O look to that final judgment of the Lord, and you will take men's
censures but as the shaking of a leaf.
4. It is God only that hath power to execute his sentence, to our
happiness or misery. "There is one lawgiver that is able to save and
to destroy," James iv. 12. If he say to us, "Come ye blessed," we
shall be happy, though devils and men should curse us; for those
that he blesseth shall be blessed. If he condemn to hell, the
applause of the world will fetch no man out, nor give him case. A
great name on earth, or histories written in their applause, or a
gilded monument over their bones, are a poor relief to damned
souls. And the barking of the wicked, and their scorns on earth, are
no diminution to the joy or glory of the souls that shine and triumph
with Christ. It is our Lord that "hath the keys of death and hell," Rev.
i. 18. Please him, and you are sure to escape, though the pope, and
all the wicked of the world, should thunder out against you their
most direful curses. Woe to us if the wicked could execute all their
malicious censures! then how many saints would be in hell! But if it
be God that justifies us, how inconsiderable a matter is it, who they
are that condemn us, or what be their pretences! Rom. viii. 33.
Direct. V. Remember that the judgment of ungodly men, is corrupted
and directed by the devil; and to be overruled by their censures, or
too much to fear them, is to be overruled by the devil, and to be
afraid of his censures of us. And will you honour him so much? Alas!
it is he that puts those thoughts into the minds of the ungodly, and
those reproachful words into their mouths. To prefer the judgment of
a man before God's, is odious enough, though you did not prefer the
devil's judgment.
Direct. VI. Consider what a slavery you choose, when you thus make
yourselves the servants of every man, whose censures you fear, and
whose approbation you are ambitious of. 1 Cor. vii. 23, "Ye are
bought with a price; be not ye the servants of men:" that is, do not
needlessly enthral yourselves. What a task have men-pleasers! they
have as many masters as beholders! No wonder if it take them off
from the service of God; for the "friendship of the world is enmity to
God;" and he that will thus be "a friend of the world, is an enemy to
God," James iv. 4. They cannot serve two masters, God and the
world. You know men will condemn you, if you be true to God: if,
therefore, you must needs have the favour of men, you must take it
alone without God's favour. A man-pleaser cannot be true to God,
because he is a servant to the enemies of his service; the wind of a
man's mouth will drive him about as the chaff, from any duty, and to
any sin. How servile a person is a man-pleaser! how many masters
hath he, and how mean ones! It perverteth the course of your
hearts and lives, and turneth all from God to this unprofitable way.
[176]

Direct. VII. Remember what a pitiful reward you seek. "Verily," saith
our Lord, concerning hypocrites and man-pleasers, "they have their
reward," Matt. vi. 25. O miserable reward! The thought and breath
of mortal men, instead of God—instead of heaven; this is their
reward! Their happiness will be to lie in hell, and remember that
they were well spoken of on earth! and that once they were
accounted religious, learned, wise, or honourable! and to remember
that they preferred this reward before everlasting happiness with
Christ! If this be not gain, your labour is all lost, which you lay out in
hunting for applause. If this be enough to spend your time for, and
to neglect your God for, and to lose your souls for, rejoice then in the
hypocrite's reward.
Direct. VIII. And remember that honour is such a thing as is found
sooner by an honest contempt of it, than by an inordinate affection
of it, and seeking it. It is a shadow which goeth from you if you
follow it, and follows you as fast as you go from it. Whose names
are now more honourable upon earth, than those prophets, and
apostles, and martyrs, and preachers, and holy, mortified christians,
who in their days set lightest by the approbation of the world, and
were made the scorn or foot-ball of the times in which they lived?
Those that have been satisfied with the approbation of their
heavenly Father, who saw them "in secret," have been "rewarded by
him openly." It is, even in the eyes of rational men, a far greater
honour to live to God, above worldly honour, than to seek it. And so
much as a man is perceived to affect and seek it, so much he loseth
of it: for he is thought to need it; and men perceive that he plays a
low and pitiful game, that is so desirous of their applause! As they
would contemn a man that should lick up the spittle of every man
where he comes, so will they contemn him that liveth on their
thoughts and breath, and honour him more that lives on God.
Direct. IX. If nothing else will cure this disease, at least let the
impossibility of pleasing men, and attaining your ends, suffice
against so fruitless an attempt. And here I shall show you how
impossible it is, or, at least, a thing which you cannot reasonably
expect.
1. Remember what a multitude you have to please; and when you
have pleased some, how many more will be still unpleased, and how
many displeased when you have done your best.[177] Alas! we are
insufficient at once to observe all those that observe us and would
be pleased by us. You are like one that hath but twelve pence in his
purse, and a thousand beggars come about him for it, and every one
will be displeased if he have it not all. If you resolve to give all that
you have to the poor, if you do it to please God, you may attain your
end; but if you do it to please them, when you have pleased those
few that you gave it to, perhaps twice as many will revile or curse
you, because they had nothing. The beggar that speeds well will
proclaim you liberal; and the beggar that speeds ill will proclaim you
niggardly and unmerciful; and so you will have more to offend and
dishonour you, than to comfort you by their praise, if that must be
your comfort.
2. Remember that all men are so selfish, that their expectations will
be higher than you are able to satisfy. They will not consider your
hinderances, or avocations, or what you do for others, but most of
them look to have as much to themselves, as if you had nobody else
to mind but them. Many and many a time, when I have had an hour
or a day to spend, a multitude have every one expected that I
should have spent it with them. When I visit one, there are ten
offended that I am not visiting them at the same hour: when I am
discoursing with one, many more are offended that I am not
speaking to them all at once: if those that I speak to account me
courteous, and humble, and respectful, those that I could not speak
to, or but in a word, account me discourteous and morose. How
many have censured me, because I have not allowed them the time,
which God and conscience commanded me to spend upon greater
and more necessary work! If you have any office to give, or benefit
to bestow, which one only can have, every one thinketh himself the
fittest; and when you have pleased one that hath it, you have
displeased all that went without it, and missed of their desires.
3. You have abundance to please that are so ignorant, unreasonable,
and weak, that they take your greatest virtues for your faults, and
know not when you do well or ill; and yet none more bold in
censuring than those that least understand the things they censure.
[178] Many and many a time my own and others' sermons have been
censured, and openly defamed, for that which never was in them,
upon the ignorance or heedlessness of a censorious hearer; yea, for
that which they directly spoke against; because they were not
understood: especially he that hath a close style, free from
tautology, where every word must be marked by him that will not
misunderstand, shall frequently be misreported.
4. You will have many factious zealots to please, who being
strangers to the love of holiness, christianity, and unity, are ruled by
the interest of an opinion or a sect; and these will never be pleased
by you, unless you will be one of their side or party, and conform
yourself to their opinions. If you be not against them, but set
yourselves to reconcile and end the differences in the church, they
will hate you as not promoting their opinions, but weakening them
by some abhorred syncretisms. As in civil, so in ecclesiastical wars,
the firebrands cannot endure the peaceable: if you will be neuters,
you shall be used as enemies. If you be never so much for Christ,
and holiness, and common truth, all is nothing, unless you be also
for them, and their conceits.
5. Most of the world are haters of holiness, and have a serpentine
enmity to the image of God, being not renewed by the Holy Ghost;
and will not be pleased with you, unless you will sin against your
Lord, and do as they do. 1 Pet. iv. 3-5, "Walking in lasciviousness,
lusts, excess of wine, revellings, banquetings, and abominable
idolatries, wherein they think it strange that ye run not with them to
the same excess of riot, speaking evil of you; who shall give account
to him that is ready to judge the quick and the dead." You must be
counted as Lot among the Sodomites, a busy fellow that comes
among them to make himself their judge, and to control them, if you
tell them of their sin. You shall be called a precise, hypocritical
coxcomb, (or somewhat much worse,) if you will not be as bad as
they, and if by your abstinence (though you say nothing) you seem
to reprehend their sensuality and contempt of God. Among bedlams
you must play the bedlam, if you will escape the fangs of their
revilings. And can you hope to please such men as these?
6. You shall have satanical God-haters, and men of seared and
desperate consciences to please, that are malicious and cruel, and
will be pleased with nothing but some horrid iniquity, and the
damning of your own souls, and drawing others to damnation. Like
that monster of Milan, that when he had got down his enemy, made
him blaspheme God in hope to save his life, and then stabbed him,
calling it a noble revenge, that killed the body and damned the soul
at once. There are such in the world, that will so visibly act the
devil's part, that they would debauch your consciences with the most
horrid perjuries, perfidiousness, and impiety, that they may triumph
over your miserable souls.[179] And if you think it worth the wilful
damning of your souls, it is possible they may be pleased. If you tell
them, we cannot please you, unless we will be dishonest, and
displease God, and sin against our knowledge and consciences, and
hazard our salvation, they will make but a jest of such arguments as
these, and expect you should venture your souls and all upon their
opinions, and care as little for God and your souls as they do.
Desperate sinners are loth to go to hell alone; it is a torment to
them to see others better than themselves. They that are cruel and
unmerciful to themselves, and have no pity on their own souls, but
will sell them for a whore, or for preferment, and honour, or sensual
delights, will scarce have mercy on the souls of others: Matt. xxvii.
25, "His blood be on us, and on our children."
7. You will have rigorous, captious, uncharitable, and unrighteous
men to please, who will "make a man offender for a word, and lay a
snare for him that reproveth in the gate, and turn aside the just for
a thing of nought, and watch for iniquity," Isa. xxix. 20, 21. That
have none of that charity which covereth faults, and interpreteth
words and actions favourably; nor none of that justice which causeth
men to do as they would be done by, and judge as they would be
judged; but judging without mercy, are like to have judgment
without mercy. And are glad when they can find any matter to
reproach you: and if once they meet with it (true or false) they will
never forget it, but dwell as the fly on the ulcerated place.[180]
8. You will have passionate persons to please, whose judgments are
blinded, and are not capable of being pleased. Like the sick and sore
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about testbank and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebooksecure.com

You might also like