C# Course – Worldwideasy – 05

C# lesson 5. I will focus on 2D Arrays, Class, Object. Finally, Interface design. It can provide extensive knowledge.

2D Arrays in C#

A two-dimensional array has a type like an int [ ] [ ] or string [ ] [ ], with two pairs of square brackets. The element of a 2D array is arranged in rows and columns, and the new operator for the 2D array specifies both the number of rows and the number of columns.

You can get an Idea Using the Example Below about 2d arrays.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] cat =
            {
                {1,2},
                {4,6},
                {8,9}
            };
            Console.WriteLine(cat[0,1]);
            Console.ReadLine();
        }
    }
}

This code Answer is 2.

Object & Class in C#

Class is collection of objects and functions.

programming class

In computer programming, a function object is a construct that allows an object with the same syntax to be called or called a normal function. Active objects are often referred to as funksters.

Object in programming

He is a simple miner to the class. In object-oriented programming, we find a class. The use of this concept revolutionized the software development industry. This made it possible to create very fast software with a small amount of code. What makes it special is the ability to reuse the code. Let’s see how to use it for C #. The following example shows how to publish and execute a class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        class book{                    // Create Class
            public String title;
            public String Author; 
            public int pages;
        }
        static void Main(string[] args)
        {
            book book1 = new book();     // Call Class
            book1.title = "Harry Potter";
            book1.Author = "JK";
            book1.pages = 450;

            Console.WriteLine(book1.pages);
            Console.ReadLine();
        }
    }
}

You can see this code do create class and call class.

Now show you how to work class using method look below example.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        public  Book (String name, int pages)
        {
            name = aname;
            pages = apages;
        }
        public bool hash()
        {
            if (pages > 200)
            {
                return true;
            }
            false{
                return false;
            }
        }
        static void Main(string[] args)
        {
            Book Book1 = new Book("magic", 280);
            Console.WriteLine(Book1.hash());
            Console.ReadLine();
        }
    }
}

This code output is True.

Work with interface in C#

Now over the php basic course. now let’s try to work with the interface. following this stape.

  • File –> New Project.
  • Select Windows Forms Application.
  • OK -> you can see empty form.
  • Now you can See Left side in toolbox.
  • Drag and Drop label.
  • Go Label properties go appearance. See Right (Clear field);
  • Drag and Drop Text Box.
  • Drag and Drop Button.
  • Double Click Button.
  • Type this code. label1.Text ="Hello" + textBox1.Text;

Now over the C# basic course. you go to this link and answer the question and get C# certificate. Get Certificate

Thank you for all!

More C# ClickHere!

See you Next Lesson Soon!

C# Course – Worldwideasy – 04

C# lesson 4. I will focus on Getting Control Statements (IF statement, Switch, loops). Finally, Create a simple Power Calculator. It can provide extensive knowledge.

A control statement is a statement that determines whether other statements are active. If a statement decides whether another statement should be executed, or one of the two statements to be executed. A loop determines the number of times another expression should be executed.

Control Statement mean

Basically have 3 control statements in php

  • IF
  • Switch
  • Loops

IF Statement in C#

If a statement is used to check the condition, it can be a condition or more. The special feature of it is that you can check any gap. The following example will make it clear to you.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int mark = Convert.ToInt32(85);
            if (mark > 50)
            {
                Console.WriteLine("Pass");
            }
            else
            {
                Console.WriteLine("Fail");
            }
            Console.ReadLine();
        }
    }
}

This code output is given as Pass. Here, it checks if the value of the mark is greater than 50. It is represented as true pass and False as Fail.

else if

This is used to check several conditions at once. look following example will make it clear to you.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int mark = Convert.ToInt32(67);
            if (mark > 75)
            {
                Console.WriteLine("A");
            }
            else if (mark > 65){
                Console.WriteLine("B");
            }
            else if (mark > 55)
            {
                Console.WriteLine("C");
            }
            else if (mark > 40)
            {
                Console.WriteLine("S");
            }
            else
            {
                Console.WriteLine("F");
            }
            Console.ReadLine();
        }
    }
}

This code output is B. You can see this code many times check conditions.

Switch

The switch expression is used to check several non-gap conditions. This works very fast and gets the idea below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            int day = 2;
            switch (day)
            {
                case 1:
                    Console.WriteLine("Sunday");
                    break;

                case 2:
                    Console.WriteLine("Monday");
                    break;

                default:
                    Console.WriteLine("Wrong");
                    break;

            }

            Console.ReadLine();
        }
    }
}

This Code output is Monday. A Break statement is used for stop the function.

Loops

Loops have main 3 loops in c#

  • For loop
  • While loop
  • Do While loop

Now I show all loops using Code. See Below all code output is the same. output is : 10,9,8,7,6,5,4,3,2,1.

For loop

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
        for (int i=10; i >= 1; i--)
            {
                Console.WriteLine(i);
            }
            Console.ReadLine();
       
        }
    }
}

While Loop

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 10;
            while (i >= 1)
            {
                Console.WriteLine(i);
                i--;
            }
            Console.ReadLine();
       
        }
    }
}

Do While Loop

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 10;
            do
            {
                Console.WriteLine(i);
                i--;
            } while (i >= 1);
            Console.ReadLine();
       
        }
    }
}

Now you have very good knowledge about C #. Practice this over and over again. Let us now see how to make a power calculator from what we have learned so far.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("****POWER CALCULATOR****");
            Console.WriteLine("Enter Base Number : ");
            int x = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter Power Number : ");
            int y = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Power is: "+getpow(x,y));
            Console.ReadLine();
       
        }
        static int getpow(int basenum, int pow)
        {
            int result = 1;
for(int i = 0; i < pow; i++)
            {
                result = result * basenum;
            }
            return result;
        }
    }
}

Thank you for all!

More C# ClickHere!

See you Next C# Lesson Soon!

C# Course – Worldwideasy – 03

Today we expect to Get User Input, Arrays, Methods, Return Types, and finally make a Simple Calculator. this all is we are doing C# console application. it uses forget good basic knowledge for C#.

C# User Input

Here we take user input and inquire how to perform a certain function. It can make more creative creations. You can get an understanding of it in the following way. See Below Example.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Your Name : ");
            String name = Console.ReadLine();
            Console.WriteLine("Your Name is " + name);
            Console.ReadLine();
        }
    }
}

This Code output is Program ask your name you can type it. after the program give output your name is “You entered the name”.

Arrays

The array is a specials type of programming language. now we can see how to work array in C # . let’s see below code example.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] num = { 1, 2, 3, 4, 5, 6 };
            Console.WriteLine(num[3]);
            Console.ReadLine();
        }
    }
}

This code output is 4. Array using the same data type list add to the program.

Method Using C#

Here we take user input and inquire how to perform a certain function. It can make more creative creations. You can get an understanding of it in the following way.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            sayhi();
            Console.WriteLine("How you");
            sayhi();
            Console.ReadLine();
        }
        static void sayhi()
        {
            Console.WriteLine("Hello World");
        }
    }
}

This code output is Hello World How You Hello World. You can try this code on your Computer.

Return Type

What is done here is to show the output that we need to take into another function in a process that is done in a method. The following example code will make it clear to you.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(cube(5));
            Console.ReadLine();
        }
        static int cube (int num)
        {
            int cube = num * num * num;
            return cube;
        }
       }
}

This code output is 125. you can see cube is a function its return type is a cube (output). main function call cube function finally get an answer.

Create Calculator using C# Console

Now we try to Create Calculator using method, input, and others. see below code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Number one : ");
            String num01 = Console.ReadLine();
            Console.WriteLine("Enter Number two : ");
            String num02 = Console.ReadLine();
            float num1 = float.Parse(num01);
            float num2 = float.Parse(num02); //convert string to float
            Console.WriteLine("Answers is: ");
            Console.WriteLine("Add = "+add(num1,num2));
            Console.WriteLine("Cut = "+cut(num1, num2));
            Console.WriteLine("Multification = "+mul(num1, num2));
            Console.WriteLine("Sub = "+sub(num1, num2));
            Console.ReadLine();

        }
        static float add(float num1,float num2)
        {
            float total = num1 + num2;
            return total;
        }//add

        static float cut(float num1,float num2)
        {
            float cut = num1 - num2;
            return cut;
        }//cut
        static float mul(float num1, float num2)
        {
            float mul = num1 * num2;
            return mul;
        }//mul
        static float sub(float num1, float num2)
        {
            float sub = num1 / num2;
            return sub;
        }//sub

       }
}

You can see below output this code doing how to convert string to float.

Now you have good knowledge of this programming language of today’s lesson. practice this code and develop your knowledge.

Thank you for all!

More C# ClickHere!

See you Next C# Lesson Soon!

C# Course – Worldwideasy – 02

Today we expect Variables, Data Types, Strings, and working with Numbers. this all is we are doing C# console application. its uses forget good basic knowledge for C#.

C# Variables

Variable is a symbol that acts as a holder for various expressions or sizes and is often used to represent an arbitrary element of a set.

You now have a broader understanding. about what a variable is. So let us explain by c #. See the below example.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
String chaName = "Harry";
int age = 30;

Console.WriteLine("my name is " + chaName);
Console.WriteLine("I am " + age);
Console.WriteLine("I like " + chaName);
Console.WriteLine("good for " + age);
Console.ReadLine();

}
}
}

This code Output is My Name is Harry. I am 30. I like Harry. good for 30. You can try this code on your pc.

C# Data Types

This is special it uses to make variables. c# is a case-sensitive language. We must first say that the type of data that the computer recognizes. There are a limited number of data types that we can identify.

Data TypeSyntax
StringString name = "Hello";
Charchar grade = 'A';
intint age = 30;
floatfloat gpa = 3.2f;
doubledouble gpa = 2.35686;
boolisMale = true;

Data Types

Strings

Strings do a lot of work. We can do it very beautifully and easily. This is very useful for tasks like changing a name. Get an understanding from the table below.

SyntaxOutput
Console.WriteLine ("hello world");hello world
Console.WriteLine ("hello \n world");hello
world
Console.WriteLine ("hello\"world");hello”world
String Ad = "hello" + "boy";
Console.WriteLine (Ad);
hello boy
String Ad = "Apple";
Console.WriteLine(Ad.Length);
5
Console.WriteLine(Ad.ToUpper());APPLE
Console.WriteLine(Ad.ToLower);apple
Console.WriteLine(Ad.Contains(“hp”);false
Console.WriteLine(Ad.Contains(“Apple”);true
Console.WriteLine(Ad.[3]);L
Console.WriteLine(Ad.Indexof(‘l’));3
Console.WriteLine(Ad.Substring(2));ple

Use for String

Work With Numbers

This allows us to see how the code makes various changes to the numbers. See the table below. Get ideas from it.

SyntaxOutput
Console.WriteLine(5+7);12
Console.WriteLine(Math.Abs (-40));40
Console.WriteLine(Math.Pow (4,2));16
Console.WriteLine(Math.Sqrt (144));12
Console.WriteLine(Math.Max (10,20));20
Console.WriteLine(Math.Min (10,20));10
Console.WriteLine(Math.Round(4.2));4
Console.WriteLine(Math.Sin(55));-0.99975517335862

Work with Numbers

More about Work with Numbers. example works.

SyntaxOutput
Console.WriteLine(8+6);14
Console.WriteLine(152-56);96
Console.WriteLine(80/5);16
Console.WriteLine(8%3);2
Console.WriteLine(8*3);24
Console.WriteLine((8+9)*(8+2));170

Operations

Now you have the basic knowledge of c #. You can get a better understanding by trying the code again.

Thank you for all!

More C# ClickHere!

See you Next C# Lesson Soon!

C# Course – Worldwideasy – 01

C # is a multi-purpose programming language with general-purpose, including static typing, robust typing, vocabulary scope, essential, expression, functional, generative, object-oriented, and component-oriented programming discipline.

Today we expect basic knowledge from installing c # on a computer to coding and outputting.

C #  created by Microsoft Corporation. The platform here is a common language infrastructure. It is best to use Microsoft Visual Studio as the editor. Also, software such as Resharper can be used. The main framework of C # is the .NET Framework, which makes it easy to create user interfaces. C # is a language commonly used to build Windows applications and games.

C# does not need to be specifically entered into the computer. It is obtained automatically installing visual studio..

Start C# Coding

  1. First you want Download And Install Visual Studio(Windows operating system).
  2. Open Visual Studio.
  3. Go file and New project.
  4. Select Visual C# to Console Application and ok.
  5. After you can see Default code in below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//Code Here 
}
}
}

The code above must be present.

First Code in C#

Let’s see how to write code to print hello world.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
Console.ReadLine(); 
}
}
}

Type the code above in the toolbar. Click the Start button and you will get the output on a black screen as shown below.

hee
Output

Now you can type the code and run it. Edit the code above and try again. Next, we are going to show any shape using only the code called writeline();.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("      **");
Console.WriteLine("      /|");
Console.WriteLine("     / |");
Console.WriteLine("    /  |");
Console.WriteLine("   /   |");
Console.WriteLine("  /    |");
Console.WriteLine(" /     |");
Console.WriteLine("|      |");
Console.WriteLine("|      |");
Console.WriteLine("|      |");
Console.WriteLine("|______|");
Console.ReadLine();
}
}
}

Thank you for all!

More C# ClickHere!

See you Next C# Lesson Soon!