Skip to main content

Posts

C # Tutorial, Methods

 Hello, Welcome to C# Tutorial. My name is Abdul Yesdani. Today we are going to learn about methods in C# programing language. Method is a bunch of code or statements which perform a single task. Here you can see the method example.     static void Hello(string name)         {             Console.WriteLine("Hello!" + name +"  Welcome to C#");             Console.WriteLine("Methods can have n number of statements");             Console.WriteLine("method will perform a single task");         } Methods can have parameters as shown in the above example, 'string name' is a parameter must be passed its value at the calling method in side the Main() method. Press Ctrl+ F5 to run the application. You will get the following output. In the above example you can see 'void'  keyword before method name. Means method return type is void , i.e., met...

C# Tutorial, Arrays

Hi, Welcome to all. My name is Abdul Yesdani. Today we are going to learn about arrays in C#. In our previous postings we have worked with variables. One variable can store only one value. If we want to store multiple values of same type, array variable is there to do that job. What is an array? An array variables is capable of storing multiple values of same type.   Syntax:  datatype[ ] arrayName = new datatype[size]; Example: int [ ] myNumbers = new int [ 5];  The above array variable  myNumbers is capable of storing 5 integer values. In the memory it will allocate 5 slots to store 5 values, index starting from 0 to 4. Array indexing will always start with 0 and end with size -1. Types of Arrays in C# : There are 3 types of array in C#.  Single dimensional array, multi dimensional array and jagged array. Single dimension array represent a single column or row of values. The above example is for the same. Multi dimension array represent 2 dimension or 3 di...

C# Tutorial, Decision making & loop statements

 Hello, Welcome to C# learning. My name is Abdul Yesdani. Today we are going to discuss about decision making or branching statements and looping or iteration statements in the C# language. Decision making statements: To make a firm decision we will use decision making statements. For this we will use specific key words such as if, if-else. example: A buyer   wants to buy a product, but he will make a decision to buy it if  the product is available for less than some x amount. int price = 180; if (price < 200)   Console.WriteLine("Buy the product"); if() statement checks Boolean value of a variable , means the value is true or false. price is assigned with 180. In the statement if (price < 200) , the boolean value is true. When the value is true the statement or block of statements which follows if will get executed. So out put will be Buy the product. int price = 280; if (price < 200)       Console.WriteLine("Buy the product"); else ...

C# Tutorial, Step-7, General Structure of a C# program

Hello, welcome to All. My name is Abdul Yesdani. Today we are learning about C# program structure. We will discuss about how the program skeleton is made of, what are the different components are in the program. C# programs can have one or more files. Each file can contain no or plenty of namespaces. A namespace can contain types such as classes, structs, interfaces, enumerations, and delegates, in addition to other namespaces. According to the program needs we can add any of above mentioned types to the project. The following is the skeleton of a C# program that contains all of these elements. No need to have all of these elements in the program, here all possible elements mentioned.  // A skeleton of a C# program using System; namespace YourNamespace {      class YourMainClass      {                static void Main(string[] args)             ...

C# Tutorial , Step-5, Built in Data Types

 Hello, Welcome to all. My name is Abdul Yesdani. Today we are going to learn about built in data types of C# language. The following list describe the C# built in types. Integral numeric types Type Description / Range bool True or false byte 0-255     Unsigned 8 bit integer sbyte -128 to 127       Signed 8 bit integer short -32,768 to 32,767         Signed 16-bit integer ushort 0 to 65,535               Unsigned 16-bit integer int -2,147,483,648 to 2,147,483,647    Signed 32-bit integer uint 0 to 4,294,967,295     Unsigned 32-bit integer long -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Signed 64-bit integer ulong 0 to 18,446,744,073,709,551,615 Unsigned 64-bit integer Floating Types float ±1.5 x 10−45 to ±3.4 x 1038             4 bytes double ±5.0 × 10−324 to ±1.7 × 10308        8 bytes decimal ±1.0 x ...

Learn C# in Easy Way, Step-4 :Type conversion with strings, numbers.

 Hi, Welcome to all. My name is Abdul Yesdani. Today I am going to teach you how to convert string to number and vice versa. Conversion is two types : Implicit type conversion and Explicit type conversion. What is implicit type conversion in C#? C# compiler automatically converts from one type to other type is called implicit conversion. Example: int items =3;                 string person ="Kamat"; When we mix these two variables and print them see what we get.          Console.WriteLine( name + "sold " + items + " Products);  Output will be : Kamat sold 3 Products. In the above statement  'items' is a numeric variable, which is automatically converted to string. What is explicit conversion in C#? We need to force convert from one type to other type. Observe the following statements. I want to add 7 to the items.  Console.WriteLine( name + "sold " + items + 7+ " Products"); When we run it we get output...