Showing posts with label Programming Language. Show all posts
Showing posts with label Programming Language. Show all posts

Tuesday, December 25, 2018

C# Data Types

C# Data Types:

Data types specify the type of data that a valid C# variable can hold. C# is a strongly typed programming language because in C#, each type of data is predefined as part of the programming language and all constants or variables defined for a given program must be described with one of the data types.

In C#, data types are categorized based on how they store their value in the memory. 

C# includes following categories of data types:
·       Value type
·       Reference type

Value Type:

Value type variables can be assigned a value directly. They are derived from the class System.ValueType. Value type holds both data and memory on the same location. A Value Type stores its contents in memory allocated on the stack. When you created a Value Type, a single space in memory is allocated to store the value and that variable directly holds a value. If you assign it to another variable, the value is copied directly and both variables work independently. Predefined datatypes, structures, enums are also value types, and work in the same way.

For Example:

Consider integer variable int i = 100;


The system stores 100 in the memory space allocated for the variable 'i'.

In C#, value types are further divided into simple types, enum types, struct types, and nullable value types.
  • Simple Types
    • Signed integral: sbyte, short, int, long
    • Unsigned integral: byte, ushort, uint, ulong
    • Unicode characters: char
    • IEEE floating point: float, double
    • High-precision decimal: decimal
    • Boolean: bool
  • Enum types
    • User-defined types of the form enum E {...}
  • Struct types
    • User-defined types of the form struct S {...}
  • Nullable value types
    • Extensions of all other value types with a null value
Reference Type:

The Reference Data Types will contain a memory address of variable value. It do not contain the actual data stored in a variable, but they contain a reference to the actual data. Reference Type variables are stored in a different area of memory called the heap. Assigning a reference variable to another variable doesn't copy the data. Instead it creates a second copy of the reference, which refers to the same location of the heap as the original value.

For example:


string s = "Hello World!!";


In C# reference types are further divided into class types, interface types, array types, and delegate types.
  • Class types
    • Ultimate base class of all other types: object
  • Interface types
    • User-defined types of the form interface I {...}
  • Array types
    • Single- and multi-dimensional, for example, int[] and int[,]
  • Delegate types
    • User-defined types of the form delegate int D(...)




Prof. Shardul P. Patil

profshardulp.patil@gmail.com

Friday, September 14, 2018

Introduction to C# Programming

Introduction to C#:
In 2000, Microsoft announced the C# programming language. C# is designed to be a simple, modern, general-purpose, object-oriented programming language, borrowing key concepts from several other languages. C# has roots in C, C++ and Java. C# has similar capabilities to Java and is appropriate for the most demanding app-development tasks, especially for building today’s large-scale enterprise apps, web-based, mobile and “cloud”-based apps. C# is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the .NET Framework.

C# is object oriented and has access to the powerful .NET Framework Class Library—a vast collection of prebuilt classes that enable you to develop apps quickly. C# is event driven programming language. You’ll write programs that respond to user-initiated events such as mouse clicks, keystrokes, timer expirations, touches and finger swipes—gestures that are widely used on smart phones and tablets. C# also allows asynchronous programming in which multiple tasks can be performed at the same time. Asynchronous make your apps more responsive to user interactions, such as mouse clicks and keystrokes, among many other uses.

The following reasons make C# a widely used professional language:
  • It is a modern, general-purpose programming language
  • It is object oriented.
  • It is component oriented.
  • It is easy to learn.
  • It is a structured language.
  • It produces efficient programs.
  • It can be compiled on a variety of computer platforms.
  • It is a part of .Net Framework.
Programming Features of C# Language:
  • Boolean Conditions
  • Automatic Garbage Collection
  • Standard Library    Assembly Versioning
  • Properties and Events
  • Delegates and Events Management
  • Easy-to-use Generics
  • Indexers
  • Conditional Compilation
  • Simple Multithreading
  • LINQ and Lambda Expressions
  • Integration with Windows