The constants refer to fixed values that the program may not alter
during its execution. These fixed values are also called literals.
Constants can be of any of the basic data types like an integer
constant, a floating constant, a character constant, or a string
literal. There are also enumeration constants as well.
পৃষ্ঠাসমূহ
Labels
Search Your Article
CS
Pageviews
Monday, January 30, 2017
C# - Operators
An operator is a symbol that tells the compiler to perform specific
mathematical or logical manipulations. C# has rich set of built-in
operators and provides the following type of operators:
C# - Decision Making
Decision making structures requires the programmer to specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.
Following is the general form of a typical decision making structure found in most of the programming languages:
Following is the general form of a typical decision making structure found in most of the programming languages:
C# - Loops
There may be a situation, when you need to execute a block of code several number of times. In general, the statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on.
C# - Encapsulation
Encapsulation is defined 'as the process of enclosing one or more items within a physical or logical package'. Encapsulation, in object oriented programming methodology, prevents access to implementation details.
C# - Methods
A method is a group of statements that together perform a task. Every
C# program has at least one class with a method named Main.
To use a method, you need to:
To use a method, you need to:
- Define the method
- Call the method
C# - Nullables
C# provides a special data types, the nullable types, to which you can assign normal range of values as well as null values.
For example, you can store any value from -2,147,483,648 to 2,147,483,647 or null in a Nullable<Int32> variable. Similarly, you can assign true, false, or null in a Nullable<bool> variable. Syntax for declaring a nullable type is as follows:
For example, you can store any value from -2,147,483,648 to 2,147,483,647 or null in a Nullable<Int32> variable. Similarly, you can assign true, false, or null in a Nullable<bool> variable. Syntax for declaring a nullable type is as follows:
< data_type> ? <variable_name> = null;The following example demonstrates use of nullable data types:
using System; namespace CalculatorApplication { class NullablesAtShow { static void Main(string[] args) { int? num1 = null; int? num2 = 45; double? num3 = new double?(); double? num4 = 3.14157; bool? boolval = new bool?(); // display the values Console.WriteLine("Nullables at Show: {0}, {1}, {2}, {3}", num1, num2, num3, num4); Console.WriteLine("A Nullable boolean value: {0}", boolval); Console.ReadLine(); } } }When the above code is compiled and executed, it produces the following result:
Nullables at Show: , 45, , 3.14157 A Nullable boolean value:
The Null Coalescing Operator (??)
The null coalescing operator is used with the nullable value types and reference types. It is used for converting an operand to the type of another nullable (or not) value type operand, where an implicit conversion is possible.Sunday, January 29, 2017
C# - Arrays
An array stores a fixed-size sequential collection of elements of the
same type. An array is used to store a collection of data, but it is
often more useful to think of an array as a collection of variables of
the same type stored at contiguous memory locations.
C# - Strings
In C#, you can use strings as array of characters, However, more common practice is to use the string keyword to declare a string variable. The string keyword is an alias for the System.String class.
C# - Structures
In C#, a structure is a value type data type. It helps you to make a
single variable hold related data of various data types. The struct keyword is used for creating a structure.
Structures are used to represent a record. Suppose you want to keep track of your books in a library. You might want to track the following attributes about each book:
Structures are used to represent a record. Suppose you want to keep track of your books in a library. You might want to track the following attributes about each book:
C# - Classes
When you define a class, you define a blueprint for a data type. This
does not actually define any data, but it does define what the class
name means. That is, what an object of the class consists of and what
operations can be performed on that object. Objects are instances of a
class. The methods and variables that constitute a class are called
members of the class.
C# - Inheritance
One of the most important concepts in object-oriented programming is
inheritance. Inheritance allows us to define a class in terms of another
class, which makes it easier to create and maintain an application.
This also provides an opportunity to reuse the code functionality and
speeds up implementation time.
Subscribe to:
Posts (Atom)