C#.Net

C#.Net

Introduction:

  • Microsoft developed C#, a new programming language based on the C and C++ languages.
  • Microsoft describes C# in this way: ”C# is a simple, modern, object–oriented, and typesafe programming language derived from C and C++.
  • C# (pronounced c sharp) is firmly planted in the C and C++ family tree of languages and will immediately be familiar to C and C++ programmers.
  • C# aims to combine the high productivity of visual basic and raw power of C++.”
  • C# is a case sensitive language.
Some aspects of C# will be familiar to those, who have programmed in C, C++, or Java. C# incorporates the Smalltalk concept, which means everything is an object. In other words, all types in C# are objects. C# properties are similar to Visual Basic language properties. The Rapid Application Development (RAD) goal in C# is assisted by C#’s use of concepts and keyword, such as class, structure, statement, operator, and enumeration. The language also utilizes the concepts contained in the Component Object Model (COM) architecture.

C# Language Features:


C# was developed as a language that would combine the best features of previously existing Web and Windows programming languages. Many of the features in C# language are preexisted in various languages such as C++, Java, Pascal, and Visual Basic. Here is a list of some of the primary characteristics of C# language.
  • Modern and Object Oriented
  • Simple and Flexible
  • Typesafety
  • Automatic Memory Management
  • Versioning Control
  • Cross Platform Interoperability

Table 3.1. The intrinsic types built into C#
C# type
Size (in bytes)
.NET type
Description
byte
1
Byte
Unsigned (values between 0 and 255).
char
2
Char
Unicode characters (a modern way of storing most characters, including international language characters).
bool
1
Boolean
True or false.
sbyte
1
SByte
Signed (values between -128 and 127).
short
2
Int16
Signed (short) (values between -32,768 and 32,767).
ushort
2
UInt16
Unsigned (short) (values between 0 and 65,535).
int
4
Int32
Signed integer values between -2,147,483,648 and 2,147,483,647.
uint
4
UInt32
Unsigned integer values between 0 and 4,294,967,295.
float
4
Single
Floating-point number. Holds the values from approximately +/-1.5 x 10-45 to approximately +/-3.4 x 1038 with seven significant figures.
double
8
Double
Double-precision floating-point. Holds the values from approximately +/-5.0 x 10-324 to approximately +/-1.8 x 10308 with 15 to 16 significant figures.
decimal
12
Decimal
Fixed-precision up to 28 digits and the position of the decimal point. This type is typically used in financial calculations. Requires the suffix "m" or "M" when you declare a constant.
long
8
Int64
Signed integers ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
ulong
8
UInt64
Unsigned integers ranging from 0 to approximately 1.85 x 1019.

Each type has a name (such as int) and a size (such as 4 bytes). The size tells you how many bytes each object of this type occupies in memory. Programmers generally don't like to waste memory if they can avoid it, but with the cost of memory these days, you don't need to be particular about the memory cost of types. Most of the time, if you're using whole numbers you'll use an int, even if a short would be fine. Likewise, double is the commonly used type for decimal numbers, even though float is just fine in most cases. The Description column in Table 3.1, "The intrinsic types built into C#" lists the minimum and maximum values you can hold in objects of each type.

No comments:

Post a Comment