Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

103260880

Download as pdf or txt
Download as pdf or txt
You are on page 1of 71

Download the Full Ebook and Access More Features - ebooknice.

com

(Ebook) C# Data Structures and Algorithms :


Explore the Possibilities of C# for Developing a
Variety of Efficient Applications by Marcin Jamro
ISBN 9781788834681, 1788834682
https://ebooknice.com/product/c-data-structures-and-
algorithms-explore-the-possibilities-of-c-for-developing-a-
variety-of-efficient-applications-51630440

OR CLICK HERE

DOWLOAD EBOOK

Download more ebook instantly today at https://ebooknice.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

(Ebook) C# Data Structures and Algorithms: Explore the


possibilities of C# for developing a variety of efficient
applications by Marcin Jamro ISBN 9781788833738,
1788833732
https://ebooknice.com/product/c-data-structures-and-algorithms-
explore-the-possibilities-of-c-for-developing-a-variety-of-efficient-
applications-24088654
ebooknice.com

(Ebook) C# Data Structures and Algorithms: Harness the


power of C# to build a diverse range of efficient
applications, 2nd Edition by Marcin Jamro ISBN
9781803248271, 1803248270
https://ebooknice.com/product/c-data-structures-and-algorithms-
harness-the-power-of-c-to-build-a-diverse-range-of-efficient-
applications-2nd-edition-55462970
ebooknice.com

(Ebook) Data Structures, Algorithms, And Applications In


C++ by Sartaj Sahni ISBN 9780929306322, 0929306325

https://ebooknice.com/product/data-structures-algorithms-and-
applications-in-c-5912596

ebooknice.com

(Ebook) Data Structures and Algorithms with the C++ STL: A


guide for modern C++ practitioners by Farrier, John ISBN
9781835468555, 1835468551
https://ebooknice.com/product/data-structures-and-algorithms-with-the-
c-stl-a-guide-for-modern-c-practitioners-55889290

ebooknice.com
(Ebook) Data Structures and Algorithms in C# by Michael
McMillan ISBN 9780521670159, 0521670152

https://ebooknice.com/product/data-structures-and-algorithms-
in-c-979682

ebooknice.com

(Ebook) Data Structures and Algorithms in C++ by Adam


Drozdek ISBN 9781133608424, 1133608426

https://ebooknice.com/product/data-structures-and-algorithms-
in-c-4630542

ebooknice.com

(Ebook) Data Mining Algorithms in C++: Data Patterns and


Algorithms for Modern Applications by Timothy Masters ISBN
9781484233146, 9781484233153, 148423314X, 1484233158
https://ebooknice.com/product/data-mining-algorithms-in-c-data-
patterns-and-algorithms-for-modern-applications-6840616

ebooknice.com

(Ebook) The C++ Standard Library: Fourth Edition includes


C++23 by Rainer Grimm

https://ebooknice.com/product/the-c-standard-library-fourth-edition-
includes-c-23-49417210

ebooknice.com

(Ebook) Options and Derivatives Programming in C++23:


Algorithms and Programming Techniques for the Financial
Industry, 3rd Edition by Carlos Oliveira ISBN
9781484298268, 9781484298275, 1484298276, 1484298268
https://ebooknice.com/product/options-and-derivatives-programming-
in-c-23-algorithms-and-programming-techniques-for-the-financial-
industry-3rd-edition-53487340
ebooknice.com
C# Data Structures and Algorithms

Explore the possibilities of C# for developing a variety of efficient


applications

Marcin Jamro
BIRMINGHAM - MUMBAI
C# Data Structures and
Algorithms
Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any
form or by any means, without the prior written permission of the publisher, except in the case of brief
quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express or implied.
Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages
caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products
mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the
accuracy of this information.

Commissioning Editor: Richa Tripathi


Acquisition Editor: Chaitanya Nair
Content Development Editor: Zeeyan Pinheiro
Technical Editor: Romy Dias
Copy Editor: Safis Editing
Project Coordinator: Vaidehi Sawant
Proofreader: Safis Editing
Indexer: Tejal Daruwale Soni
Graphics: Jason Monteiro
Production Coordinator: Shantanu Zagade

First published: April 2018

Production reference: 1170418

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-78883-373-8

www.packtpub.com
mapt.io

Mapt is an online digital library that gives you full access to over
5,000 books and videos, as well as industry leading tools to help you
plan your personal development and advance your career. For more
information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical
eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content


PacktPub.com
Did you know that Packt offers eBook versions of every book
published, with PDF and ePub files available? You can upgrade to the
eBook version at www.PacktPub.com and as a print book customer, you are
entitled to a discount on the eBook copy. Get in touch with us at
service@packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical


articles, sign up for a range of free newsletters, and receive
exclusive discounts and offers on Packt books and eBooks.
Contributors
About the author
Marcin Jamro, PhD, is an entrepreneur and researcher, as well as a
developer and architect of various kinds of applications. He is the
President of the Board at TITUTO Sp. z o.o. [Ltd.] in Rzeszów,
Poland.

Marcin is interested in many aspects of computer science, including


software engineering and project management. He is an author of
two other books, namely Windows Phone 8 Game Development
(2013) and Windows Application Development Cookbook (2017),
both by Packt Publishing.

Marcin has published several papers, participated in many


conferences, organized a few of them, and participated in two
internships at Microsoft in Redmond, USA. He has the MCP, MCTS,
and MCPD certificates.
About the reviewer
Dariusz Rzońca, PhD, received his BSc in Mathematics from the
University of Rzeszow, Poland, in 2002, MSc in Computer
Engineering from the Rzeszow University of Technology, Poland in
2004, and PhD in Computer Science at the Silesian University of
Technology, Poland, in 2012. He has been working as an assistant
professor in the Department of Computer and Control Engineering at
Rzeszow University of Technology, Poland. Dariusz is the author or
co-author of over sixty scientific papers.
Packt is searching for authors
like you
If you're interested in becoming an author for Packt, please visit autho
rs.packtpub.com and apply today. We have worked with thousands of

developers and tech professionals, just like you, to help them share
their insight with the global tech community. You can make a
general application, apply for a specific hot topic that we are
recruiting an author for, or submit your own idea.
Table of Contents
Title Page

Copyright and Credits

C# Data Structures and Algorithms

Packt Upsell

Why subscribe?

PacktPub.com

Contributors

About the author

About the reviewer

Packt is searching for authors like you


Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

1. Getting Started

Programming language

Data types

Value types

Structs
Enumerations

Reference types

Strings

Object

Dynamic

Classes

Interfaces
Delegates

Installation and configuration of the IDE

Creating the project

Input and output

Reading from input

Writing to output

Launching and debugging

Summary

2. Arrays and Lists

Arrays

Single-dimensional arrays

Example – month names

Multi-dimensional arrays

Example – multiplication table

Example – game map

Jagged arrays

Example – yearly transport plan

Sorting algorithms

Selection sort

Insertion sort

Bubble sort

Quicksort

Simple lists
Array list

Generic list
Example – average value

Example – list of people


Sorted lists

Example – address book


Linked lists

Example – book reader


Circular-linked lists

Implementation
Example – spin the wheel

Summary
3. Stacks and Queues
Stacks
Example – reversing words

Example – Tower of Hanoi


Queues

Example – call center with a single consultant


Example – call center with many consultants

Priority queues
Example – call center with priority support

Summary
4. Dictionaries and Sets

Hash tables
Example – phone book

Dictionaries
Example – product location

Example – user details


Sorted dictionaries

Example – definitions


Hash sets

Example – coupons


Example – swimming pools

"Sorted" sets
Example – removing duplicates

Summary
5. Variants of Trees

Basic trees
Implementation

Node
Tree

Example – hierarchy of identifiers


Example – company structure

Binary trees
Implementation

Node
Tree

Example – simple quiz


Binary search trees
Implementation
Node

Tree
Lookup

Insertion
Removal
Example – BST visualization

AVL trees
Implementation
Example – keep the tree balanced
Red-black trees

Implementation
Example – RBT-related features
Binary heaps
Implementation

Example – heap sort


Binomial heaps
Fibonacci heaps
Summary

6. Exploring Graphs
Concept of graphs
Applications
Representation

Adjacency list
Adjacency matrix
Implementation
Node

Edge
Graph
Example – undirected and unweighted edges
Example – directed and weighted edges

Traversal
Depth-first search
Breadth-first search
Minimum spanning tree

Kruskal's algorithm
Prim's algorithm
Example – telecommunication cable
Coloring

Example – voivodeship map


Shortest path
Example – game map

Summary
7. Summary
Classification of data structures
Diversity of applications

Arrays
Lists
Stacks
Queues

Dictionaries
Sets
Trees
Heaps

Graphs
The last word
Other Books You May Enjoy
Leave a review - let other readers know what you think
Preface
As a developer, you have certainly heard about various data
structures and algorithms. However, have you ever thought
profoundly about them and their impact on the performance of your
applications? If not, it is high time to take a look at this topic, and
this book is a great place to start!

The book covers many data structures, starting with simple ones,
namely arrays and a few of their variants, as representatives of
random access data structures. Then, lists are introduced, together
with their sorted variant. The book also explains limited access data
structures, based on stacks and queues, including a priority queue.
Following this, we introduce you to the dictionary data structure,
which allows you to map keys to values and perform fast lookup.
The sorted variant of the dictionary is supported, as well. If you
want to benefit from high-performance, set-related operations, you
can use another data structure, namely a hash set. One of the most
powerful constructs is a tree, which exists in a few variants, such as
a binary tree, a binary search tree, as well as a self-balancing tree
and a heap. The last data structure we analyze is a graph, which is
supported by many interesting algorithmic topics, such as graph
traversal, minimum spanning tree, node coloring, and finding the
shortest path in a graph. There is a lot of content ahead of you!

Are you interested in knowing the influence of choosing a suitable


data structure on the performance of your application? Do you want
to know how you can increase the quality and performance of your
solution by choosing the right data structure and accompanying
algorithm? Are you curious about real-world scenarios where these
data structures can be applied? If you answer positively to any of
these questions, let's start reading this book to learn about various
data structures and algorithms that you can use while developing
applications in C#.
Arrays, lists, stacks, queues, dictionaries, hash sets, trees, heaps,
and graphs, as well as accompanying algorithms—a broad range of
subjects awaits you in the next pages! Let's start the adventure and
take the first step toward your mastery of data structures and
algorithms, which hopefully will have a positive effect on your
projects and on your career as a software developer!
Who this book is for
This book is aimed at developers who would like to learn about the
data structures and algorithms that can be used in C# in various
kinds of applications, including web and mobile solutions. The topics
presented here are suitable for programmers with various levels of
experience, and even beginners will find interesting content.
However, having at least a basic knowledge of the C# programming
language, such as about object-oriented programming, will be an
added advantage.

To easily understand the content, the book is equipped with many


illustrations and examples. What's more, the source code for the
accompanying projects is attached to the chapters. Thus, you can
easily run example applications and debug them without writing the
code on your own.

It is worth mentioning that the code can be simplified, and it can


differ from the best practices. What's more, the examples can have
significantly limited, or even no, security checks and functionalities.
Before publishing your application using the content presented in the
book, the application should be thoroughly tested to ensure that it
works correctly in various circumstances, such as in the scenario of
passing incorrect data.
What this book covers
, Getting Started, explains the very important role of using
Chapter 1

the right data structures and algorithms, as well as the impact it has
on the performance of the developed solution. The chapter briefly
introduces you to the topic of the C# programming language and
various data types—both value and reference. Then, it presents the
process of the installation and configuration of the IDE, as well as
the creation of a new project, developing the example application,
and debugging using breakpoints and the step-by-step technique.

Chapter 2, Arrays and Lists, covers scenarios of storing data using two
kinds of random access data structures, namely arrays and lists.
First, three variants of arrays are explained, that is, single-
dimensional, multi-dimensional, and jagged. You will also get to
know four sorting algorithms, namely selection, insertion, bubble
sort, and quicksort. The chapter also deals with a few variants of
lists, such as simple, sorted, double-linked, and circular-linked.

, Stacks and Queues, explains how to use two variants of


Chapter 3

limited access data structures, namely stacks and queues, including


priority queues. The chapter shows how to perform push and pop
operations on a stack, and also describes the enqueue and dequeue
operations in the case of a queue. To aid your understanding of
these topics, a few examples are presented, including the Tower of
Hanoi game and an application that simulates a call center with
multiple consultants and callers.

, Dictionaries and Sets, focuses on data structures related to


Chapter 4

dictionaries and sets, which make it possible to map keys to values,


perform fast lookup, and carry out various operations on sets. The
chapter introduces you to both nongeneric and generic variants of a
hash table, the sorted dictionary, and the high-performance solution
to set operations, together with the concept of the "sorted" set.
, Variants of Trees, describes a few tree-related topics. It
Chapter 5

presents the basic tree, together with its implementation in C#, and
examples showing this in action. The chapter also introduces you to
binary trees, binary search trees, and self-balancing trees, namely
AVL and red-black trees. The remainder of the chapter is dedicated
to heaps as tree-based structures, that is, the binary, binomial, and
Fibonacci heaps.

, Exploring Graphs, contains a lot of information about


Chapter 6

graphs, starting with an explanation of their basic concepts,


including nodes and a few variants of edges. The implementation of
a graph in C# is also covered. The chapter introduces you to two
modes of graph traversal, namely depth-first and breadth-first
search. Then, it presents the subject of minimum spanning trees
using Kruskal's and Prim's algorithms, the node coloring problem,
and the solution to finding the shortest path in a graph using
Dijkstra's algorithm.

, Summary, is the conclusion to all the knowledge acquired


Chapter 7

from the previous chapters. It shows a brief classification of data


structures, dividing them into two groups, namely linear and
nonlinear. Finally, the chapter talks about the diversity of the
applications of various data structures.
To get the most out of this
book
The book is aimed at programmers with various experience.
However, beginners will also find some interesting content.
Nevertheless, at least a basic knowledge of C#, such as about
object-oriented programming, will be an added advantage.
Download the example code
files
You can download the example code files for this book from your
account at www.packtpub.com. If you purchased this book elsewhere, you
can visit www.packtpub.com/support and register to have the files emailed
directly to you.

You can download the code files by following these steps:

1. Log in or register at www.packtpub.com.


2. Select the SUPPORT tab.
3. Click on Code Downloads & Errata.
4. Enter the name of the book in the Search box and follow the
onscreen instructions.

Once the file is downloaded, please make sure that you unzip or
extract the folder using the latest version of:

WinRAR/7-Zip for Windows


Zipeg/iZip/UnRarX for Mac
7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://githu
b.com/PacktPublishing/C-Sharp-Data-Structures-and-Algorithms. In case there's an

update to the code, it will be updated on the existing GitHub


repository.

We also have other code bundles from our rich catalog of books and
videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the
screenshots/diagrams used in this book. You can download it here: h

ttps://www.packtpub.com/sites/default/files/downloads/CSharpDataStructuresandAlgorit

hms_ColorImages.pdf .
Conventions used
There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, folder names, filenames, file


extensions, pathnames, dummy URLs, and user input. Here is an
example: "The class contains three properties (namely Id, Name, and
Role), as well as two constructors."

A block of code is set as follows:


int[,] numbers = new int[,] =
{
{ 9, 5, -9 },
{ -11, 4, 0 },
{ 6, 115, 3 },
{ -12, -9, 71 },
{ 1, -6, -1 }
};

Any command-line input or output is written as follows:


Enter the number: 10.5
The average value: 10.5 (...)
Enter the number: 1.5
The average value: 4.875

Bold: Indicates a new term, an important word, or words that you


see onscreen. For example, words in menus or dialog boxes appear
in the text like this. Here is an example: "When the
message Installation succeeded! is shown, click on
the Launch button to start the IDE."
Warnings or important notes appear like this.

Tips and tricks appear like this.


Get in touch
Feedback from our readers is always welcome.

General feedback: Email feedback@packtpub.com and mention the book


title in the subject of your message. If you have questions about any
aspect of this book, please email us at questions@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy


of our content, mistakes do happen. If you have found a mistake in
this book, we would be grateful if you would report this to us. Please
visit www.packtpub.com/submit-errata, selecting your book, clicking on the
Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any
form on the Internet, we would be grateful if you would provide us
with the location address or website name. Please contact us at
copyright@packtpub.com with a link to the material.

If you are interested in becoming an author: If there is a topic


that you have expertise in and you are interested in either writing or
contributing to a book, please visit authors.packtpub.com.
Reviews
Please leave a review. Once you have read and used this book, why
not leave a review on the site that you purchased it from? Potential
readers can then see and use your unbiased opinion to make
purchase decisions, we at Packt can understand what you think
about our products, and our authors can see your feedback on their
book. Thank you!

For more information about Packt, please visit packtpub.com .


Getting Started
Developing applications is certainly something exciting to work on,
but it is also challenging, especially if you need to solve some
complex problems that involve advanced data structures and
algorithms. In such cases, you often need to take care of
performance to ensure that the solution will work smoothly on
devices with limited resources. Such a task could be really difficult
and could require significant knowledge regarding not only the
programming language, but also data structures and algorithms.

Did you know that replacing even one data structure with another
could cause the performance results to increase hundreds of times?
Does it sound impossible? Maybe, but it is true! As an example, I
would like to tell you a short story about one of the projects in which
I was involved. The aim was to optimize the algorithm of finding
connections between blocks on a graphical diagram. Such
connections should be automatically recalculated, refreshed, and
redrawn as soon as any block has moved in the diagram. Of course,
connections cannot go through blocks and cannot overlap other
lines, and the number of crossings and direction changes should be
limited. Depending on the size and the complexity of the diagram,
the performance results differ. However, while conducting tests, we
have received results in the range from 1 ms to almost 800 ms for
the same test case. What could be the most surprising aspect is that
such a huge improvement has been reached mainly by... changing
data structures of two sets.

Now, you could ask yourself the obvious question: which data
structures should I use in given circumstances and which algorithms
could be used to solve some common problems? Unfortunately, the
answer is not simple. However, within this book, you will find a lot of
information about data structures and algorithms, presented in the
context of the C# programming language, with many examples,
code snippets, and detailed explanations. Such content could help
you to answer the aforementioned questions while developing the
next great solutions, which could be used by many people all over
the world! Are you ready to start your adventure with data
structures and algorithms? If so, let's start!

In this chapter, you will cover the following topics:

Programming language
Data types
Installation and configuration of the IDE
Creating the project
Input and output
Launching and debugging
Programming language
As a developer, you have certainly heard about many programming
languages, such as C#, Java, C++, C, PHP, or Ruby. In all of
them, you can use various data structures, as well as implement
algorithms, to solve both basic and complex problems. However,
each language has its own specificity, which could be visible while
implementing data structures and accompanying algorithms. As
already mentioned, this book will focus only on the C# programming
language, which is also the main topic of this section.

The C# language, pronounced as "C Sharp", is a modern, general-


purpose, strongly-typed, and object-oriented programming language
that can be used while developing a wide range of applications, such
as web, mobile, desktop, distributed, and embedded solutions, as
well as even games. It cooperates with various additional
technologies and platforms, including ASP.NET MVC, Windows Store,
Xamarin, Windows Forms, XAML, and Unity. Therefore, when you
learn the C# language, as well as getting to know more about data
structures and algorithms in the context of this programming
language, you can use such skills to create more than one particular
type of software.

The current version of the language is C# 7.1. It is worth mentioning


its interesting history with the following versions of the language (for
example, 2.0, 3.0, and 5.0) in which new features have been added
to increase language possibilities and to simplify the work of
developers. When you take a look at release notes for particular
versions, you will see how the language is being improved and
expanded over time.

The syntax of the C# programming language is similar to other


languages, such as Java or C++. For this reason, if you know such
languages, you should quite easily be able to understand the code
written in C#. As an example, similarly as in the languages
mentioned previously, the code consists of statements that end with
semicolons (;), and curly brackets ({ and }) are used to group
statements, such as within the foreach loop. You could also find
similar code constructions, such as the if statement, or while and for
loops.

Developing various applications in the C# language is also simplified


by the availability of many additional great features, such as
Language Integrated Query (LINQ), which allows developers to
get data from various collections, such as SQL databases or XML
documents, in a consistent way. There are also some approaches to
shorten the required code, such as using lambda expressions,
expression-bodied members, getters and setters, or string
interpolation. It is worth mentioning the automatic garbage
collection that simplifies the task of releasing memory. Of course, the
solutions mentioned are only the very limited subset of features
available while developing in C#. You will see some others in the
following parts of this book, together with examples and detailed
descriptions.
Data types
While developing applications in the C# language, you could use
various data types, which are divided into two groups, namely value
types and reference types. The difference between them is very
simple—a variable of a value type directly contains data, while a
variable of a reference type just stores a reference to data, as shown
as follows:

As you can see, a Value type stores its actual Value directly in the
Stack memory, while a Reference type only stores a Reference
here. The actual value is located in the Heap memory. Therefore, it
is also possible to have two or more variables of a reference type that
reference exactly the same value.

Of course, a difference between value and reference types is very


important while programming and you should know which types
belong to the groups mentioned. Otherwise, you could make
mistakes in the code that could be quite difficult to find. For instance,
you should remember to take care while updating the data of a
reference type, because the change could also be reflected in other
variables that are referencing the same object. Moreover, you should
be careful while comparing two objects with the equals (=) operator,
because you could compare the reference, not the data itself, in the
case of two instances of a reference type.
The C# language also supports pointer types, which can be declared as type* identifier or
void* identifier. However, such types are beyond the scope of this book. You can read more
about them at: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/unsafe-code-
pointers/pointer-types.
Value types
To give you a better understanding of data types, let's start with the
analysis of the first group (that is, value types), which could be
further divided into structs and enumerations.
More information is available at: https://docs.microsoft.com/en-us/dotnet/csharp/language-refe
rence/keywords/value-types.
Structs
Within structs, you have access to many built-in types, which could
be used either as keywords or types from the System namespace.

One of them is the Boolean type (the bool keyword), which makes it
possible to store a logical value, that is, one of two values, namely
true or false.

As for storing integer values, you can use one of the following
types: Byte (the byte keyword), SByte (sbyte), Int16 (short), UInt16 (ushort),
Int32 (int), UInt32 (uint), Int64 (long), and UInt64 (ulong). They differ by the

number of bytes for storing values and therefore by the range of


available values. As an example, the short data type supports values
in the range from -32,768 to 32,767 while uint supports values in the
range from 0 to 4,294,967,295. Another type within the integral
types is Char (char), which represents a single Unicode character such
as 'a' or 'M'.

In the case of floating-point values, you can use two types,


namely Single (float) and Double (double). The first uses 32 bits, while
the second uses 64 bits. Thus, their precision differs significantly.

What's more, the Decimal type (the decimal keyword) is available. It


uses 128 bits and is a good choice for monetary calculations.

An example declaration of a variable in the C# programming


language is as follows:
int number;

You can assign a value to a variable using the equals sign (=), shown
as follows:
number = 500;
Of course, declaration and assignment could be performed in the
same line:
int number = 500;

If you want to declare and initialize an immutable value, that is, a


constant, you can use the const keyword, as shown in the following
line of code:
const int DAYS_IN_WEEK = 7;
More information about the built-in data types, together with the complete list of ranges, is
available at: https://msdn.microsoft.com/library/cs7y5x0x.aspx.
Enumerations
Apart from structs, the value types contain enumerations. Each
has a set of named constants to specify the available set of values.
For instance, you can create the enumeration for available languages
or supported currencies. An example definition is as follows:
enum Language { PL, EN, DE };

Then, you can use the defined enumeration as a data type, as


shown as follows:
Language language = Language.PL;
switch (language)
{
case Language.PL: /* Polish version */ break;
case Language.DE: /* German version */ break;
default: /* English version */ break;
}

It is worth mentioning that enumerations allow you to replace some


magical strings (such as "PL" or "DE") with constant values and this
has a positive impact on code quality.
You can also benefit from more advanced features of enumerations, such as changing the
underlying type or specifying values for particular constants. You can find more information at: ht
tps://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/enum.
Reference types
The second main group of types is named reference types. Just as
a quick reminder, a variable of a reference type does not directly
contain data, because it just stores a reference to data. In this
group, you can find three built-in types, namely string, object, and
dynamic. Moreover, you can declare classes, interfaces, and delegates.

More information about the reference types is available at: https://docs.microsoft.com/en-us/do


tnet/csharp/language-reference/keywords/reference-types.
Strings
There is often the necessity to store some text values. You can
achieve this goal using the String built-in reference type from the
System namespace, which is also available using the string keyword.

The string type is a sequence of Unicode characters. It can have zero


chars, one or more chars, or the string variable can be set to null.

You can perform various operations on string objects, such as


concatenation or accessing a particular char using the [] operator, as
shown as follows:
string firstName = "Marcin", lastName = "Jamro";
int year = 1988;
string note = firstName + " " + lastName.ToUpper()
+ " was born in " + year;
string initials = firstName[0] + "." + lastName[0] + ".";

At the beginning, the firstName variable is declared, and the "Marcin"


value is assigned to it. Similarly, "Jamro" is set as a value of the lastName
variable. In the third line, you concatenate five strings (using the +
operator), namely, the current value of firstName, the space, the
current value of lastName converted to the upper-case string (by calling
the ToUpper method), the string " was born in ", and the current value of
the year variable. In the last line, the first chars from firstName and
lastName variables are obtained, using the [] operator, as well as

concatenated with two dots to form the initials, that is, M.J., which
are stored as a value of the initials variable.

The Format static method could also be used for constructing the
string, as follows:
string note = string.Format("{0} {1} was born in {2}",
firstName, lastName.ToUpper(), year);

In this example, you specify the composite format string with


three format items, namely the firstName (represented by {0}), upper-
case lastName ({1}), and the year ({2}). The objects to format are
specified as the following parameters.
More information is available at: https://docs.microsoft.com/en-us/dotnet/csharp/language-refe
rence/keywords/string.

It is also worth mentioning the interpolated string, which uses


interpolated expressions to construct a string. To create a string
using this approach, the $ character should be placed before ", as
shown in the following example:
string note = $"{firstName} {lastName.ToUpper()}
was born in {year}";
More information is available at: https://docs.microsoft.com/en-us/dotnet/csharp/language-refe
rence/keywords/interpolated-strings.
Object
The Object class, declared in the System namespace, performs a very
important role while developing applications in the C# language
because it is the base class for all classes. It means that built-in
value types and built-in reference types, as well as user-defined
types, are derived from the Object class, which is also available by
using the object alias.

As the object type is the base entity for all value types, it means that
it is possible to convert a variable of any value type (for example, int
or float) to the object type, as well as to convert back a variable of the
object type to a specific value type. Such operations are named

boxing (the first one) and unboxing (the other). They are shown
as follows:
int age = 28;
object ageBoxing = age;
int ageUnboxing = (int)ageBoxing;
More information is available at: https://docs.microsoft.com/en-us/dotnet/csharp/language-refe
rence/keywords/object.
Dynamic
Apart from the types already described, the dynamic one is available
for developers. It allows the bypassing of type checking during
compilation so that you can perform it during the run time. Such a
mechanism is useful while accessing some application
programming interfaces (APIs), but it will not be used in this
book.
More information is available at: https://docs.microsoft.com/en-us/dotnet/csharp/language-refe
rence/keywords/dynamic.
Classes
As already mentioned, C# is an object-oriented language and
supports declaration of classes together with various members,
including constructors, finalizers, constants, fields, properties,
indexers, events, methods, and operators, as well as delegates.
Moreover, classes support inheritance and implementing interfaces.
Static, abstract, and virtual members are available, as well.

An example class is shown as follows:


public class Person
{
private string _location = string.Empty;
public string Name { get; set; }
public int Age { get; set; }

public Person() => Name = "---";

public Person(string name, int age)


{
Name = name;
Age = age;
}

public void Relocate(string location)


{
if (!string.IsNullOrEmpty(location))
{
_location = location;
}
}

public float GetDistance(string location)


{
return DistanceHelpers.GetDistance(_location, location);
}
}

The Person class contains the _location private field with the default
value set as the empty string (string.Empty), two public properties (Name
and Age), a default constructor that sets a value of the Name property
to --- using the expression body definition, an additional
constructor that takes two parameters and sets values of properties,
the Relocate method that updates the value of the private field, as well
as the GetDistance method that calls the GetDistance static method from
the DistanceHelpers class and returns the distance between two cities in
kilometers.

You can create an instance of the class using the new operator. Then,
you can perform various operations on the object created, such as
calling a method, as shown as follows:
Person person = new Person("Mary", 20);
person.Relocate("Rzeszow");
float distance = person.GetDistance("Warsaw");
More information is available at: https://docs.microsoft.com/en-us/dotnet/csharp/language-refe
rence/keywords/class.
Random documents with unrelated
content Scribd suggests to you:
a stone roller for threshing rice and a shovel for winnowing. Manure,
consisting of horse and cow droppings, night soil and ashes, was
bought in the city at the rate of threepence per donkey load, and
used freely on the land, which was a rich alluvial loam; the frequent
storms also deposited layers of dust which were regarded as good
for the crops.
The house, which Isa Haji owned and had built room by room as he
could afford it, at a total cost (including the land) of £50, covered a
square of sixty feet. The guest-room, in which he lived during the
summer and in which the meals were cooked and served, was about
twenty feet square and was lighted by a hole in the roof. A mud
platform covered with felts, on which the family slept, occupied a
prominent position, and the chief piece of furniture was a carved box,
which held clothes and served as a bedstead. Above it was a shelf
full of Russian teapots. Off this room opened the store-room, in
which grain was kept for winter consumption and which served as
the living-room in winter. There was also a courtyard partly roofed in
with matting during the summer, in which grew a shady tree, and this
was the chief working room of the wife and daughters-in-law at that
season. Here we noticed a cradle, a spinning-wheel and various
pans. Two small rooms belonged to two unmarried sons, and the
rest of the square contained stabling, an oven and a store for dry
fodder.
THE SONS OF ISA HAJI PLOUGHING.
Page 304.

The home was managed by the wife and her three daughters-in-law,
who cooked the food, looked after the children and made the
clothes. They did not work in the fields, but spun the cotton into yarn,
which they wove into the rough white calico of which most of the
clothing of the poorer classes is fashioned.
The staple food of the family was bread made from millet, a grain
that is held to be more sustaining than wheat or rice. Isa Haji’s large
family consumed all his share of the crops, except the lucerne and
some of the melons, turnips, carrots and linseed, which were sold.
The oil of the linseed was used for cooking and lighting.
The chief meal of these peasant-farmers was eaten at sunset and
consisted of suyukash, a soup prepared from pieces of paste-like
macaroni and vegetables boiled in water. In the morning they took
tea with cream and salt, and fruit and bread were eaten at odd
hours. Meat, generally beef, appeared on their table only once a
week. There was plenty of this rude fare, supplemented by slices of
pumpkin eaten hot and by other delicacies; and Isa Haji’s sons
appeared healthy, their teeth being noticeably fine and sound. They
said that they suffered a good deal from lack of warmth in the winter,
as charcoal was dear and had to be used sparingly. They placed a
bowl of lighted charcoal under a wooden frame, over which a quilt
was thrown, and the family sat by day and slept by night under this
covering, with their feet towards the centre.
Isa Haji had been the tenant of the farm for more than ten years. It
included three small properties belonging to three Kashgar
merchants. Two-thirds of the lucerne, amounting in value to about
five pounds, and one half of the other crops, were paid over as rent.
He had no security of tenure, and could be turned out at will, but the
prospect of this appeared to him unlikely, and he expressed
satisfaction with his lot.
The farm paid revenue to the extent of 105 lbs. of wheat, a similar
quantity of millet and 2100 lbs. of chopped straw, Isa Haji and his
landlords each paying one half of the whole. There had also to be
met the demand of the Chinese authorities for forced labour on
public works and transport, but this was compounded for in money
and might come to the equivalent of two shillings per annum.
Nothing was paid for the use of irrigation water, and the taxation
represented less than 5 per cent of the two main crops. In the case
of villages situated at some distance from the city double this amount
may be taken by the tax collectors, who are more exacting in
proportion to their distance from headquarters.
To sum up, we have an oasis in which agriculture is not affected by
the rainfall, but depends entirely on the rivers. The peasants have
enough to eat, a good climate and neighbours in abundance. There
are few parts of the world where the people are so contented, and,
although discontent might perhaps bring an improvement of their lot,
it is pleasant to see such cheerful, friendly tillers of the soil leading a
healthy agricultural life, and to meet them returning home at night
singing their tuneful songs:

How happy he who crowns in shades like these


A youth of labour with an age of ease;
Who quits a world where strong temptations try,
And, since ’tis hard to combat, learns to fly.
CHAPTER XVII
MANNERS AND CUSTOMS IN CHINESE TURKESTAN

Straight and slender-waisted are the maids of Kashgar,


Short, with sack-like figures, are the maids of Yangi Hissar.
A goitre above and fat below are the maids of Yarkand.
Arranging apples on saucers are the maids of Khotan-Ilchi.
Wearing felt caps, with foreheads high, are the maids of Sarikol.

The Maids of Turkestan. (From an old ballad.)

The inhabitants of Chinese Turkestan are divided by the


anthropologist into four distinct groups. The first consists of the
Sarikoli and Pakhpo mountaineers, who are pure Aryans. The
second is a desert group including the mass of the inhabitants of the
country, the basis of this population being Aryan with some Uighur
admixture, more especially at Aksu in the north. The third group is
formed of the Kirghiz, the Dulanis and the inhabitants of Aksu; the
fourth consists of the Chinese and Mongols, whose differentiation
from the Kirghiz is to be noted. The Aryan type has been best
preserved in the southern and south-western parts of the province,
with their rugged mountain areas which are difficult of access. In the
western districts Turkish influence is evident, in the northern the
Mongol zone begins, and this, as our survey moves eastwards, gives
place to the Chinese.
Throughout this work reference is constantly made to the people of
Chinese Turkestan, and here an attempt will be made to summarize
their character. They are distinctly to be classified as “tame,” in the
frontier officer’s sense of the word, being submissive, lacking in spirit
and ready to serve any master, provided that they can enjoy life in
their own way, with feasting, women and music. In their ballads they
complain of forced labour, with its separation from wife and family,
and they sing the praises of the home. But they are not faithful to
their wives: “Let every one follow his inclination and enjoy himself
with the woman he prefers. If the kings were just, every one would
have his beloved mistress at his side.” Lack of physical and moral
energy and dislike of hard, continuous work and, above all, of
discipline, are notable characteristics of these apathetic oasis-
dwellers; but against these imperfections, which they share, more or
less, with the neighbouring peoples of Russian Turkestan, must be
set many good qualities. Hospitality is found everywhere, strangers
are welcomed and the people are pleasant to deal with, their
politeness being especially marked. The Chinese rule, though
supported by few troops, is a living force, and this proves that the
people are law-abiding. Moreover, there is very little fanaticism, and
the inhabitants of Chinese Turkestan, although obedient to their
spiritual leaders, are not easily excited to rebellion. One inconsistent
trait in this home-loving race is the readiness they show to undertake
a journey, though travelling is generally hard and wearisome; but
perhaps the chief cause of this is curiosity, and, after all, relatively
few travellers leave their beloved province. “We love our festivals” is
the general refrain of this happy, but nonchalant, race of lotos-eaters.
During the months we spent in this little-known country, I employed
my spare time in collecting information regarding its manners and
customs, which, as is natural, bore strong traces of Chinese origin.
They were also influenced by the fact that the people were Buddhists
for many hundreds of years before their forcible conversion to Islam
in the tenth century, when they became Sunnis, looking up to the
Khan of Bokhara and, above him, to the Sultan of Turkey. Their holy
places remained unchanged so far as the sites were concerned, and
on them shrines in honour of Moslem saints have been erected.
Ancestor-worship, too, is inherited from the Chinese, with the result
that the tombs are visited with a frequency unknown elsewhere in
Central Asia.
Girls, when they reach a marriageable age, visit one of the shrines
and pray as follows: “O Allah, O Lord of the Shrine, grant me a
house with a kettle ready placed on the stove, and a spoon in the
kettle. May it be a house with its four sides decorated with cloth, with
carpets and druggets ready spread, and with towels hanging from
the pegs. Grant me a husband whose father and mother are dead;
and may he have no other wife!” When the saint vouchsafes to hear
this delightfully naïve petition and a suitor appears on the scene,
there is no formal betrothal, although in the case of the wealthy large
sums are paid by the bridegroom and the bride is richly dowered.
Costly gifts, too, are given to the bride by the bridegroom and by
relatives and friends. In the case of a poor man, a payment of merely
one or two pounds sterling is made to the parents, who defray the
bride’s outfit from the money. The next step taken is to obtain a
certificate from the Imam of the quarter, that the woman is free to
marry, and after the payment of a small fee a written permission for
the marriage is given by the local Beg.
Nowadays there is no special wedding-dress, and even the globular
wedding-cap of cloth of gold or silver has ceased to be worn. The
marriage ceremony is generally celebrated at the termination of a
feast which lasts until the evening. A mulla reads the fatiha or
opening chapter of the Koran, after which the agent of the bride goes
to the women’s apartment and asks her thrice whether she accepts
the bridegroom, and upon receiving her bashfully given consent, he
returns to the men to announce the success of his mission, thereby
completing the nikah or legal ceremony. Two pieces of bread soaked
in salt water are then given to the bridegroom and bride respectively,
and this, in popular opinion, is the most important act of the
marriage. Indeed many marriages are contracted by the observance
of this custom alone, bread and salt probably symbolizing the
inauguration of a new household, although the meaning has now
been forgotten.
As the bride leaves her old home, the mother laments: “O my black-
eyed darling! Alas, my child, my child! My sweet-voiced, soft-eyed
darling! My daughter leaves me, and I remain in an empty house.
Alas, my child, my child!”
When conducted to her new home, the people of the quarter bar her
path by means of a fire, and demand gifts in the shape of
handkerchiefs. The groom, too, will not allow her to dismount from
her horse until he is handsomely fee’d, and finally, when the bride
enters her husband’s house, flour and cotton are set before her and
given away to the poor. This ceremony is termed Ak-Yul-luk or
“White Road,” and symbolizes a happy journey through life. During
the lifetime of the older generation the bridegroom is called kiau oghli
or “son-in-law” by the parents, and the bride kelin or “daughter-in-
law,” but she is spoken of as a chaukan or married woman by her
neighbours.
There is an immense difference between the villagers and the
townspeople in Kashgar, both in the position of women and in their
morality. The villagers as a rule marry only one wife and rarely
practise divorce, and their wives take a high position inherited from
pre-Islamic days. For example, it is customary to agree, before the
reading of the nikah, that the wife shall be taken to the shrine of
Hazrat Apak for tawwuf or “circling” of the tomb when the apricots
are ripe, other stipulations being that the woman cannot be taken to
another town without her consent, and sometimes that the husband
shall not take another wife. The women may frequently be seen
riding to market on good horses and attending to business almost on
an equality with the men. In the city wives are constantly divorced,
so much so that the majority of them remarry many times. Temporary
marriages, resembling in effect sigheh marriages in Persia, are also
very common, and some women systematically indulge in divorces
in order to gain money. They cannot remarry until after the expiration
of the iddat of three months and ten days, but upon receiving two
letters of divorce—generally obtained in different towns—they can
remarry at once by using the older letter. It is an indication of the low
position held by women in the towns that a merchant, on starting off
to business, will sometimes return home if he first meets one of the
fair sex, this being looked upon as a bad omen.
Constant intermarriage, as in most Moslem countries, produces sad
results in the form of idiocy, deafness and dumbness in the offspring,
such visitations being especially noticeable among the rich, landed
classes, who intermarry generation after generation, in order to keep
the family property intact. So far is this policy pursued that in the
richest family of Kashgar many of the girls have perforce remained
single because there were not enough cousins to go round. It is
interesting to note that in this matter the Chinese go to the opposite
extreme, the whole nation being divided up into about one hundred
divisions, and no man being permitted to marry a woman of his own
division, although she be in no way related to him.
In Kashgar, marriage is not the chief event in a woman’s life, the
ceremony of chachbagh or “braiding of the hair” being far more
important, although held at no fixed time after marriage, and not
depending on the birth of a child. It is celebrated by a great feast,
with dancing, which sometimes lasts for three days. Gifts, far richer
than those given at marriage, are bestowed on the wife, the parents
in many cases handing over landed property. The culminating point
is the appearance of the woman, who, attired in her richest clothes,
takes the seat of honour in the room; and then, in the presence of all,
her hair, hitherto worn in four or five plaits, is formally and for the first
time braided in two plaits, and she becomes thereby a jawan. She is
now entitled to wear five red semicircular strips of embroidery on the
right side of the neck of her gown, one below the other, and
increasing successively in length. In the case of the rich, Indian cloth
of gold is generally used.
One day a woman was seen weeping at a shrine, and her prayer
was as follows: “O Holy One! What shall I do? How shall I live? I
have been left an orphan. I am become a stranger. What shall I do?
Am I to suffer the hardships of an orphan? Am I to remain lonely? I
have no father, no mother. Every one is oppressing me. O Allah, I
am lost among friends and foes. Alas, my stranger’s fate! Alas, my
orphan’s fate! O Holy One, put love into the heart of my husband and
make his mind just towards me. O Allah, grant me the wish of my
heart, give me a son, a son with a long life. I have become a
stranger. Thou hast left me an orphan. O Allah, help me and make
my enemies like dust.”
After this fervent prayer the suppliant, with her eyes shut, put her
hand into a hole in the tomb and drew forth a morsel of earth, which
she swallowed. Her faith was justified, and in due course of time she
began to make arrangements for an easy delivery, to ensure which a
visit was paid to a bakhshi or magician. He played upon a drum and
chanted some incoherent gibberish, the woman meanwhile holding a
rope that hung from the roof, and dancing round it until giddiness
ensued. After this ceremony she paid a fee, gave alms to the poor,
and returned home with her heart at ease. Later on she visited the
tombs of her ancestors, taking with her an offering of food, and
begged them to intercede for an easy delivery and, above all, for the
birth of a son. She laid the offering near the grave, praised her
ancestors, lamented her own failings, walked round the tomb seven
times and finally distributed the food to the beggars. About a month
before the event, she went on foot to a place where there were
seven water mills, and after slowly crossing the seven ducts that fed
them, returned home with happy confidence in the special efficacy of
the ceremony.
A MAGICIAN AND HIS DISCIPLE.
Page 314.

When her hour was come, no one was allowed to leave the house
unless upon business that was urgent, in which case no harm was
anticipated, provided that some article of dress was left behind. The
women of the neighbourhood assembled to help, and during the
delivery cried out with the idea of keeping the birth a secret, a
custom adopted from the Chinese. The newly born infant, too, was
carefully concealed from visitors.
If former children belonging to the parents have all died, which is,
alas, a frequent occurrence, the father, dressed as a beggar, takes
the baby to the bazar and begs from the shopkeepers small pieces
of calico, which are made into a shirt, the idea being to avoid
misfortune by thus humbling himself. Special names signifying “solid”
or “stay” or “may he stay!” are in such cases given to the child when
he is named, between the third and seventh day, by a mulla, who
first whispers the azan or call to prayer into his ear. On the fortieth
day the head of the infant is shaved and the hair buried. A sheep is
sacrificed and eaten on this occasion, while its bones, which must
not be broken, are buried.
The rite of circumcision, one of the most important of the “five
foundations” of Islam, is performed between the third and eighth
years. The barber operates, and in the case of the rich the event is
celebrated by a feast lasting two or three days, at which the boy
receives presents including hard-boiled eggs, with which he plays a
game by knocking them together.
Children of both sexes are sent to school very young, the idea being
that they will gradually pick up their letters. Education in Kashgar
merely consists of learning by heart a chapter of the Koran and its
Turki equivalent. The letters are taught, penmanship is encouraged,
and lessons are given in the forms of prayer and of ablution.
Geography, history (as distinct from legend), mathematics and
foreign languages are utterly neglected, and the girls leave school at
about ten and most of the boys a year or two later. The teachers are
narrow-minded bigots, and the parents are content to have it so, with
the result that there is not much progress in Kashgar.
We visited the chief boys’ school in Kashgar, where the master bade
his favourite pupils recite passages from the Koran. This they did in
a lugubrious sing-song, swaying backwards and forwards as if in
pain. The pedagogue and his scholars were then photographed,
holding imposing leather-bound and silver-embossed books, which
on enquiry proved to be commentaries on the Koran.

A KASHGAR SCHOOL.
Page 316.

The death ceremonies are in general those common to Islam


throughout Asia, but there are also some customs peculiar to
Kashgar. The body, after being washed and shrouded, is laid out
with the thumbs of the hands and the big toes tied together, while the
chin is also tied up. It is then carried out of the house and, at seven
paces from the door, a spoonful of rice water is poured on the
ground. At every seven steps this is repeated, and the following
verse recited:

Zir[16] has come, Zabar has come,


From the centre of the earth news has come.
O swift dogs of the door of heaven,
Come, open the gates of paradise for this man.

This mention of dogs is due to Chinese influence; in Islam they


occupy a degraded position and are considered unclean. Contrary to
the general usage of Islam, white is the mourning colour, as in
China. The funeral procession to the grave is headed by professional
mourners, and accompanied by a mulla, who reads sentences from
the Koran on the way, and conducts the service at the grave.
Women do not attend at the graveside, but mourn at a neighbouring
mosque: “O my father! My brave father! My good father!” or “O my
mother! My beautiful mother with black eyebrows! Thou leavest us
and we are alone.” One curious custom is that of driving a stick into
the grave near the head of the corpse, which Grenard considers to
be a survival of the ancient practice of offering food to the dead. On
the third day a solemn feast is held in the house of the deceased.
The mourning lasts for forty days, and upon the termination of this
period a second feast is given, and the normal life is then resumed
by the mourners.
The system of medicine at Kashgar is based on the ancient Greek
theory as taught by Hippocrates, Galen and Plato, whose works
were translated into Arabic and Persian, especially by Abu Ali bin
Sina, known in Europe as Avicenna. Diseases are divided into the
categories of “hot” and “cold,” to be cured by medicines and food of
the opposite category. For instance, in the case of fever, cock’s flesh,
which is “cold,” is eaten, or fish. Hen’s flesh is considered “hot” in
Persia, but in Kashgar there is some difference of opinion among the
faculty.
The Kashgar doctors believe implicitly in giving pigeon’s or duck’s
blood in cases of poisoning, and, moreover, prescribe the flesh of a
nestling sparrow torn in two to ease swellings in the groin; they stop
bleeding by means of a pad composed of burnt felt, or a bit of leather
covered with mud or filth. Rheumatism and dropsy are treated by
burying the patient in hot sand or by wrapping him in the skin of a
recently killed sheep, and abdominal complaints by sticking several
lighted candles into a loaf and placing it on the patient’s stomach.
So much for the doctors of Kashgar; but, as their reputation is very
low, recourse is had to other means of curing sickness. Among the
most common is the female diviner, who, when called in, kneads
flour into a ball, recites some gibberish in which the names of the
archangels and of Solomon are mentioned, and solemnly buries the
ball under the fire, reciting the names of all the holy men who are
buried in the neighbourhood. Whichever of these saints is being
mentioned when the ball bursts has to be propitiated. Oil is taken to
his shrine, where it is boiled and the steam is inhaled by the patient,
after which it is mixed with food, part of which is distributed to the
poor and part eaten for seven days by the sufferer. This ceremony is
termed chachratku or “bursting of a ball of kneaded flour” and is
regarded as most efficacious.
The power of the evil eye is firmly believed in by all classes, and
children usually wear round their necks a little leather case
containing a verse of the Koran as a protection against it. If a child is
believed to be possessed, an old woman recites the following:
“Allah is sublime. Praise be to Allah! There is no god but Allah. If
thou art an evil eye depart, as this place is not for thee. Go to a
deserted watermill; go to a deserted house; go to a grave; go to the
house of the Kazi. These are the commands of Allah, of Solomon
and of the Saint.” The evil eye cannot withstand this invocation and
leaves the sufferer forthwith.
In cases of possession by the devil, a magician is called in, and
chants as follows: “Another head has come to the head; another
body has come to the body. Your master has come; a jade lamp and
blood sherbet are here. You will soon be like ashes, for I have an
iron knife to cut you with and coal bullets to shoot you with.” The
devil, hearing these threats from the magician, quits the patient
without more ado.
Among general remedies are the following: The eyes of sheep
sacrificed at the Id-i-Gurban at Mecca are dried and kept as powerful
charms for sickness. When used they are moistened and applied to
the forehead. Another remedy consists of bread and meat, collected
from seven bakers and butchers. The food, when prepared, is taken,
together with a doll, to the grave of a saint, after which some of it is
eaten and the remainder distributed to the poor. This effects the
cure. Yet another curious treatment is to cover up the patient’s head
while a man walks round him with lighted straw, uttering certain
special prayers during the fumigation.
As to children’s ailments: if a child cries too much, straw is swept up
from three roads, dust is taken from the footprints of passers-by and
Syrian rue is collected from the desert; the mixture is then lighted
and the child is cured by being held over the smoke. If a child suffers
from deafness, one method is to call in the services of a trumpeter,
who spits into the ear, while another plan is to cut seven small twigs,
wrap them up in cotton and, on market day, to tie the little bundle to
the ear of a donkey loaded with salt. For other ailments, seven coral
beads are thrown into a spring; or, again, copper pieces are begged
from seven men named Mohamed, others are added by the parents,
and a charm is made to hang round the child’s neck.
Finally, there are certain shrines famous for the cure of specific
diseases. For skin disease a shrine known as the Sigm is much
frequented. There mud is taken from a well outside and thrown at the
wall with a prayer to the saint, after which the suppliant walks away
without looking back.
A WOMAN THROWING MUD TO EFFECT A CURE.
Page 320.

I conclude this brief account of the treatment of diseases in Kashgar


by a story entitled “The Clever Physician”:[17]
“Once upon a time there was a physician. When this physician
entered the room where the sick person was, he looked all about it,
and whatever met his eyes in the shape of an eatable, he looked at
the patient and said, ‘You have eaten such and such a thing and that
is what has done you harm.’ The physician had a pupil, and
wherever the physician went, there went his pupil with him. A rich
man had become paralysed, that is to say, unable to walk. Many
physicians had treated him, but his disease did not abate. At last,
having heard that the aforesaid physician’s pupil was a wonderful
medical adept, he summoned him to his house.
“When the physician’s pupil had entered the house and had carefully
looked round, he perceived that there was nothing at all in the shape
of an eatable in it, but in one corner of the room an old donkey-
saddle had been thrown down. When he saw this he exclaimed, ‘Oh,
rich man! you have eaten an old donkey-saddle, through which your
disease has increased and you have become paralysed.’ When he
said this, the rich man was very angry, and exclaiming, ‘Does one
who is called a human being eat donkey-saddles?’ sprang up in his
rage in order to beat him and—walked!
“The physician, poor fellow, was terrified and had fled away. The rich
man was struck with wonder and exclaimed, ‘This is a great man; for
my leg, which grew no better for any physician’s medicine, has now
become quite well through this person.’ He caused the physician’s
pupil to be summoned, apologized to him, and sent him away with
many valuable gifts.”
At the first fall of snow a man frequently calls on a friend with some
snow wrapped in an envelope, while in another are enclosed verses:

My dear friend with this document I throw you snow;


From joy of heart this game arose;
Cups and jugs we have collected and wooden trays;
And we have prepared sweetmeats.
The mandoline, violin, zither and tambourine we have made ready.
When snow has fallen in winter, do not people give entertainments?
If there are friends living around do not people invite them?
If you are clever enough to seize the man who has brought the snow,
Powder his face, paint him like a girl, and beat him severely.

The visitor places his verses secretly in the house and then
decamps. If the owner of the house catches him he beats him, paints
his face like a girl and leads him through the streets calling out, “This
is the punishment for the man who throws snow”; and the visitor is
then bound to give an entertainment. But if the owner of the house
does not catch the visitor, he himself must prepare a banquet. If he
fails to do so within a week, bulrushes are tied on the top of his door,
and if this hint is not sufficient, the bier from the cemetery is placed
outside his house.
Owing to Chinese influence, there is no Moslem country where
respect for parents and for superiors is so strong as in Kashgar.
During the lives of the parents they are never referred to by name by
their children, but are always addressed as “My Lord.” A son will
never sit in the presence of his father without special permission, but
will stand with the head bowed and hands folded in token of humility.
He would never dream of retiring to sleep before his father, nor of
smoking in his presence. To superiors deference is shown by
dismounting from horseback, and by always prefacing an answer
with taksir or “fault,” which has come to be the equivalent of our “Sir.”
Upon receipt of a robe of honour, the recipient bows low, sweeping
the arms in a circle to stroke the beard. Women courtesy by bowing
low with folded hands.
The Kashgaris have few games, but kite-flying, an elementary form
of rounders, pitch-and-toss into a hole with walnuts or coins, and a
kind of tip-cat are favourite amusements. Grown-up men indulge in
ram-fighting and partridge-fighting, heavy bets being made on the
contests.
Music is extremely popular, the Kashgar peasants being distinctly
musical, and their refrains, sung in unison on returning from work,
are pleasing to the European ear. The usual instruments are the
tambourine, the mandoline and the four-stringed rubab. In Kashgar
dancing is regarded as improper, and is indulged in only by
professional women or boys; but in the Khotan oasis, among the
Dulanis of Merket, the Sarikolis and the Kirghiz, men and women
dance together at weddings. At entertainments the men and women
sit on opposite sides and, when the music commences, a woman
rises and places a handkerchief in front of a man, who thereupon
rises also, sings a song and returns the handkerchief. This is done
by all present, and men and women then dance together.
During my stay in Chinese Turkestan I sought for any custom which
might be a survival from the days of the Nestorian Christians. One
such is that horse-dealers, when a bargain is not concluded, make
the sign of the cross on the horse to avert the evil eye. It is
interesting to note that, owing to Chinese influence, black and dark
grey are the favourite colours for horses, whereas few people care to
buy a roan, whose colour is deemed unlucky.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like