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;

After You can see the below output.

Output

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!

Leave a Comment

Your email address will not be published. Required fields are marked *

Translate »