C#

C# (pronounced Csharp) is a new programming language introduced by Microsoft with the Microsoft .NET framework. It was first created in the late 1990’s as part of Microsoft’s.NET strategy. It is a new language free of backward compatibility and a bunch of new, exciting and promising features.
It is an Object Oriented Programming language, which at its core, and has similarities with Java, C++ and VB. The main brains behind C# were Anders Hejlsberg and Scott Wiltamuth. However, many other personalities like Rob Howard, Scott Guthrie were also involved behind C# and the .NET Framework.

Primitive Data Types in C#

The built-in data type in C# is called primitive data types. Here we are giving you the range of most commonly used primitive data types in C#.   Data Type Description Size (bits) Range int Whole numbers 32 <->‡231 through 231 <-> 1 long Whole numbers 64 <-> §263 through 263 <-> 1 Float Floating-point …

Primitive Data Types in C# Read More »

The Value Type In C#

Creating Fields and Using Initializers The first type of class member we’ll take a look at is the field, also called a data member.Outside any method, A field is just a class-level variable, outside any method. If you create your field public, it’s accessible using an object of your class; for example, take a look …

The Value Type In C# Read More »

Operators & Variables In C#

C# has a number of standard operators, taken from C, C++ and Java. Most of these should be quite familiar to programmers; the less common ones are enclosed elsewhere.   Standard operators list are given below. Note that when we are writing any classes classes it is possible to change the default behaviors of some …

Operators & Variables In C# Read More »

Type Conversions in c#

Type conversion is a process of converting one type into another. Using C# type conversion techniques, not only you can convert data types, you can convert object types also. The type conversion in C# can be either implicit conversion or an explicit conversion.   If one type of data is automatically converted into another type …

Type Conversions in c# Read More »

Enums In C#

“The great power comes with a great responsibility.”   Enums are basically a set of named constants. They are declared in C# using the keyword enum. Every enum type automatically derives from System.Enum namespace and thus we can use System.Enum methods on our Enums.   Enums are value types and are created on the stack …

Enums In C# Read More »

Type-Safety in C#

At the first, what is type safe code and why is it relevant to secure programming? Type safety is certainly one of the most confusing aspects for somebody learning .Net. When .Net was released, it had a tag attached claiming that the programs developed in .Net are more stable when compared to programs developed using …

Type-Safety in C# Read More »

Scope of the Variable in C#

The scope of a variable is simply the region of the program in which that variable is usable. Scope applies to methods as well as variables. The scope of an identifier (of a variable or method) is linked to the location of the declaration that introduces the identifier into the program.   Local Scope   …

Scope of the Variable in C# Read More »

Control Statement in C#

C# uses two types of control statements: ? Conditional Statements ? Looping   Conditional Statements   In C#, there are two types of conditional statements: ? if statements ? switch statements   if statements   The first conditional statement is programmer’s favorite “if” statement. It has three forms:   1. Single selection 2. if-then-else selection …

Control Statement in C# Read More »

Class & Objects in C#

Class   A class is the most powerful data type in C#. Like structures, a class defines the data and behavior of the data type. It is nothing but a variable of type Object. Programmers can create objects that is called instance of a class. Unlike structures, classes support inheritance, a fundamental part of object-oriented …

Class & Objects in C# Read More »

Interfaces in C#

C# language does not support multiple inheritance. To solve this problem, Microsoft introduced interfaces into C#. They are regarded as an alternative to multiple inheritance. All interfaces should be declared with the keyword Interface.   You can implement any number of interfaces in a single derived class. A method declared inside the interface doesn’t contain …

Interfaces in C# Read More »

Abstract Class in C#

The abstract class is a special type of class which contains at least one abstract method. It should be declared with the keyword abstract. Every abstract class consists of one or more abstract methods. These methods will only have the method definitions i.e. abstract class will not have any method body, such as the instance …

Abstract Class in C# Read More »

Sealed Class in C#

Classes declared with the sealed keyword cannot be extended. That means, when you declare a base class with this keyword, you cannot use it in a derived class. In other words the class cannot be extended. This keyword is similar to that of final keyword in Java.   The given example SealedClass.cs is a modified …

Sealed Class in C# Read More »

Polymorphism in C#

Poly means many and morph means form. Thus, polymorphism refers to being able to use many forms of a type without regard to the details. One of the basic concepts of object oriented software development is polymorphism. The word polymorphism (from the Greek meaning “having multiple forms”) in OOP is the characteristic of being able …

Polymorphism in C# Read More »

overloading in C#

Constructors are also functions and can be parameterized (takes parameters as input)and they can be overloaded. They allow flexibility while creating an object. Suppose there is a Rectangle class declared in the System.Drawing namespace. It can be instantiated by either of the two methods.   Using Default Constructor Using Parameterized Constructor   Method 1: Using …

overloading in C# Read More »

Scroll to Top