245897 cazuri COVID-19 în Moldova
9091 – cazuri active
231235 – cazuri vindecate
5571 – cazuri fatale
Actualizarea datelor: 19 aprilie 2021 ora 11:20


C# Basics

Now that you understand a little more about what C# can do, you will want to learn how to use it.
This chapter on the basics of C# will give you a good start in that direction by providing you with a basic knowledge of the fundamentals of C# programming, which we will build on in subsequent chapters. The main topics we will be covering are:
❑ Declaring variables
❑ Initialization and scope of variables
❑ Predefined C# data types
❑ Dictating the flow of execution within a C# program using loops and conditional
statements
❑ Enumerations
❑ Namespaces
❑ The Main() method
❑ Basic command line C# compiler options
❑ Using System.Console to perform console I/O
❑ Using documentation features in C# and Visual Studio .NET
❑ C# identifiers and keywords
❑ Recommended guidelines and conventions for good programming in C#.

By the end of this chapter you will know enough C# to write simple programs, though without using inheritance or other object-oriented features, which are covered in the following chapters.

Before We Start

As we have already mentioned, C# is an object-oriented language. As we get you up to speed in the fundamentals
of the C# language, we will be assuming that you have a good grasp of the concepts behind
object-oriented (OO) programming. In other words, we will expect you to understand what we mean
by classes, objects, interfaces, and inheritance. If you have programmed in C++ or Java before, you should
have a pretty good grounding in object-oriented programming (OOP). However, if you do not have a
background in OOP, there are plenty of good sources of information on this subject. You can start with
Appendix A, which presents a detailed introduction to OOP concepts and is posted at www.wrox.com.
We also recommend Beginning Visual C#, the revised edition of Beginning C# for .NET v1.0 (ISBN
0-7645-4382-2) which teaches both object-oriented programming and C# from scratch.
If you are an experienced developer in Visual Basic 6, C++, or Java, you should note that we will make
many comparisons between C#, C++, Java, and Visual Basic 6 as we walk you through the basics of C#.
However, you might prefer to learn C# initially by reading a comparison between C# and your selected
language. If so, we have also made available separate documents for download on the Wrox Press Web
site (www.wrox.com) that give introductions to C# from the point of view of each of those languages.

Our First C# Program
Let’s start in the traditional way by compiling and running the simplest possible C# program—a simple
class consisting of a console application that writes a message to the screen.

The Code
Type the following into a text editor (such as Notepad), and save it with a .cs extension (for example,
First.cs):
using System;
namespace Wrox.ProCSharp.Basics
{
class MyFirstCSharpClass
{
static void Main()
{
Console.WriteLine(“This isn’t at all like Java!”);
Console.ReadLine();
return;
}
}
}
The following chapters present a number of code samples. The most common technique for writing C#
programs is to use Visual Studio .NET to generate a basic project and add your own code to it. However,
since the aim of these early chapters is to teach the C# language, we are going to keep things simple and
avoid relying on Visual Studio .NET until Chapter 12. Instead, we will present the code as simple files
that you can type in using any text editor and compile from the command line.

Sursa
2007-07-14 20:04:00



Comenteaza





Ultimele 25 posturi adăugate

06:50:36Cum a ajuns Filat să-l preseze pe Șor sau „Давай познакомимся, Илан!” —» un alt blog
06:07:44Rețetă delicioasă de Brownie Cake cu produsele Dr.Oetker —» Life is too short to wear boring clothes. - A blog about travel, lifestyle, healthy life and fashio
23:22:14Ils sont partout! —» APort | "Pentru un român care știe citi, cel mai greu lucru e să nu scrie." I.L. Carag
07:00:23Maratonul de rugăciune pentru țară și biserici —» Moldova Creștină
05:41:19Lucruri pe care le recomand pentru primele luni cu bebe și care mi-au făcut viața mai ușoară —» Sunt MAMĂ!
21:06:21Primarul din Căzănești te bate dacă filmezi. Polițiste în acțiune! —» Curaj.TV | Media alternativă
20:11:27Poliţist blajin fără mască, călare pe motor, defila prin zona Obor —» Curaj.TV | Media alternativă
14:38:22Schimbările —» Viata pe Tinder – Viata amoroasa pe Tinder
12:01:55Preşedintele Ucrainei cere ca țara sa să fie primită în NATO şi UE: „Nu putem sta la nesfârşit în sala de aşteptare” —» Elena Robu
07:00:25Curat nu doar în Post —» Moldova Creștină
21:15:08What’s New in the Block Editor: New Page Layout Picker, Better Block Transformation Options, and More —» costica
19:59:00Despre limitele/pericolele libertății de exprimare #palavre —» Curaj.TV | Media alternativă
13:41:25Cu grijă pentru alții —» Moldova Creștină
13:20:29Retete de Pasti – brosura online la doar 2.90 EURO —» Bucataria Talinei - condimentat cu dragoste
12:41:22Curtea Constituțională: Sunt întrunite condițiile de dezolvare a Parlamentului —» Elena Robu
08:40:35Va fi sau nu dizolvat Parlamentul de la Chișinău? Discursul Maiei Sandu la Curtea Constituțională —» Elena Robu
08:22:14Ce semnifică Termenul Creativitate ? —» Biblioteca de Arte 'Tudor Arghezi'
05:55:39Ap și, alde macovei și angajații din media le-au mulțumit la cei din Partidul Șor și „Pentru Moldova”? —» un alt blog
20:22:00Inspecție civică la Ciulnița (2 p) —» Curaj.TV | Media alternativă
19:53:37Introducing Milestone Notifications —» costica
19:01:05”Cei care așteaptă rușii...”(parodie)* —» Andrei LANGA. Blogul personal
15:24:37Conducerea Ministerului Sănătății a fost demisă. E o reacție rapidă a mafiei? —» Curaj.TV | Media alternativă
14:55:00Poliția nu poartă centura decît cu mască —» Curaj.TV | Media alternativă
14:44:00Despre fanteziile sexuale —» Curaj.TV | Media alternativă
14:27:00Paznicul fără mască se caută la prohab cînd îi arăt svastica —» Curaj.TV | Media alternativă