Chapter 1: Introduction to Visual C# Programming

Chapter 1: Introduction to Visual C# Programming


Microsoft Visual C# 2005 is an object-oriented programming language used to develop applications targeting the .NET environment. Programming languages are not unlike natural languages such as Spanish, Latin, French, Chinese, or English—human languages that are written or spoken. Each natural language includes rules that describe proper syntax and structure; we use these rules to convey cohesive thoughts and ideas. A natural language also evolves over time, sometimes from or within a genus of other languages. Programming languages share many of these attributes and also include rules for proper syntax and structure and often evolve from other languages.

Acquiring proficiency in a programming language is similar to obtaining a high level of competency in a natural language. Having acquired a level of competency in FORTRAN, Turkish, English, COBOL, Spanish, German, C, and other languages (not necessarily in that order), I speak from experience. Languages are languages. When you're learning a human language, your goals are literacy and being able to have a conversation. If, as a student of French, you can sit in a Parisian café and read the menu while discussing current events with the locals, your language skills are a fait accompli. The goal of this chapter is the same: for you to become conversational in C#.

Learning a language typically begins with core elements of language. In English, these elements include consonants, vowels, nouns, verbs, adjectives, phrases, and sentences. They represent the building blocks of the language; you cannot read, write, or speak English without a fundamental understanding of these language components. The key elements of C# are symbols and tokens, keywords, expressions, statements, functions, and classes. Effective C# programming requires, of course, a fundamental understanding of these elements, which this chapter will provide.

As you know, a sentence in English is more than random words terminated with a period. Likewise, in C#, a programming statement is more than a collection of random clauses. The following English sentence and C# statement are both nonsensical:

  • Programming fun is C#.

for(i<5;int i=0;++i)

In both cases, the correct elements are present, but the structure is incorrect. Using either a human language or a programming language to convey cohesive ideas, concepts, tasks, or instructions requires organizing the words and other elements of the language correctly. In the English language, syntax (the rules of a language) indicates where a linking verb is placed in relation to the noun object. By comparison, C# syntax orders the clauses of a for statement. According to C# syntax, the previous for statement should be structured like this: for(int i=0;i<5;++i). Understanding the underlying language syntax is equally important for natural and programming languages. This chapter will also provide the basic syntax of the C# language.

Mandarin Chinese is a tonal language, whereas English is a stress language. Learning Chinese is more than simply assimilating new words and sentence structures. You must also learn tones because the meaning of a Chinese word can change based on tone. Speaking Chinese with English enunciation would be confusing and amusing at best. Similarly, C# is an object-oriented language, not a procedural language (more on this difference later). C#, C++, Java, SmallTalk, Eiffel, and other object-oriented languages are only as effective as your appreciation of object-oriented concepts and programming techniques. I recommend a basic knowledge of object-oriented analysis and design concepts as a complement to the newly acquired C# skills this book will give you.

Finally, languages do not emerge spontaneously. Natural languages have been evolving for nearly 150,000 years, and knowing the heritage of and the influences on a language can be informative and helpful. For example, English, French, German, Yiddish, and related languages are heavily influenced by their Latin language heritage. As such, they have common words, syntax, and structures that are characteristic of the Latin metalanguage. The origin of C# does not date back centuries, but an understanding of its evolution is invaluable.