Introduction

C-Sharp (C#) :

C# is a modern, general-purpose, object-oriented programming language developed by Microsoft and approved by Ecma and ISO.

C# was developed by Anders Hejlsberg and his team during the development of .Net Framework.

C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows use of various high-level languages to be used on different computer platforms and architectures.

The following reasons make C# a widely used professional language:
  1. Modern, general-purpose programming language
  2. Object oriented.
  3. Component oriented.
  4. Easy to learn.
  5. Structured language.
  6. It produces efficient programs.
  7. It can be compiled on a variety of computer platforms.
  8. Part of .Net Framework.
  9. Integration with Microsoft Windows.

Object Oreinted Programming:

A type of programming in which programmers define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure. In this way, the data structure becomes an object that includes both data and functions. In addition, programmers can create relationships between one object and another. For example, objects can inheritcharacteristics from other objects.
One of the principal advantages of object-oriented programming techniques over procedural programming techniques is that they enable programmers to create modules that do not need to be changed when a new type of object is added. A programmer can simply create a new object that inherits many of its featuresfrom existing objects. This makes object-oriented programs easier to modify.

Data Type:

In computer science and computer programming, a data type or simply type is a classification identifying one of various types of data, such as real-valued, integer or Boolean, that determines the possible values for that type; the operations that can be done on values of that type; the meaning of the data; and the way values of that type can be stored.

Almost all programming languages explicitly include the notion of data type, though different languages may use different terminology. Common data types may include:

  • Integers,
  • Booleans,
  • Characters,
  • Floating-point numbers,
  • Alphanumeric strings.

Boolean Type :
The Boolean type represents the values: true and false. Although only two values are possible, they are rarely implemented as a single binary digit for efficiency reasons. Many programming languages do not have an explicit boolean type, instead interpreting (for instance) 0 as false and other values as true.

Integers Type:
The integer type represents the numeric values and ranges. The following table sorts out the C# integer variables so you’ll always know the range and size of each.


C# Floating Point Variable Types:
C# floating point variables come in two types: float and double. The following table compares these two types in terms of size, range, and accuracy.
TypeSize (bytes)RangeAccuracyIn Use
float81.5 x 10–45 to 3.4 x 10386–7 digitsfloat f = 1.2F;
double165.0 x 10–324 to 1.7 x 1030815–16 digitsdouble d = 1.2;

Characters Data Type:
To store alphanumeric text, such as letters, numbers, spaces, symbols, and punctuation, use the Character data type. To prevent data in Character fields from being translated across code pages, use the Character (Binary) field type.

Character fields or variables and Character (Binary) fields can store text information that is not used in mathematical calculations, such as names, addresses, and numbers. For example, phone numbers or zip codes, though they include mostly numbers, are actually best stored as character values.

Define a Class in C# ?
In C#, as in most object-oriented programming languages, a class is a bundling of unlike data and functions that logically belong together into one tidy package. Good classes are designed to represent concepts.
When you define a class, you define a blueprint for a data type. This doesn't actually define any data, but it does define what the class name means, that is, what an object of the class will consist of and what operations can be performed on such an object. Objects are instances of a class. The methods and variables that constitute a class are called members of the class.

Syntax:
{
class "name"

{
data types or formulas used;
}
}

Example:

{
    class Box
    {
       public double length;   // Length of a box
       public double breadth;  // Breadth of a box
       public double height;   // Height of a box
    }






No comments:

Post a Comment