Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Test

using System.IO;
using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, World!");
    }
}

C# OOP Virtual

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

namespace Virtual
{
    // Object Oriarted programming
    // Virtual methods and Override

    // class mine
    class parson
    {
        
        // methods
        public void myAge()
        {
            Console.WriteLine("my addris is ");
        }

        virtual public void myWork()
        {
            Console.WriteLine("i work ");
        }
    }

    // inheritance
    class programmeng:parson
    {
        public override void myWork()
        {
            base.myWork();
            Console.Write("programmeng");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            programmeng prog = new programmeng();
            prog.myWork();

        }
    }
}

C# OOP Override And New

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

namespace overrideAndNew
{
    // Object Orianted Programing
    // Override and New

    // class mine
    class parson
    {
        virtual public void msg()
        {
            Console.WriteLine("i am a parson");
        }
    }

    // class inheritance
    class programming : parson
    {
        // new mithod
        public new void msg()
        {
            Console.WriteLine("i am programming");
        }
    }

    // class inheritance
    class doctor:parson
    {
        // Override mithod
        public override void msg()
        {
            Console.WriteLine("i am a doctor");
        }
    }

    // king class
    class Program
    {
        static void Main(string[] args)
        {
            programming prog = new programming();
            doctor doc = new doctor();

            // Line One
            Console.Write("Line One ");
            parson mine = new programming();
            mine.msg(); // this Write is Parson

            // Line Tow
            Console.Write("Line Tow ");
            mine = new doctor();
            mine.msg(); // this Write is Doctor

            // Line Three
            Console.Write("Line Three ");
            parson test2 = new doctor();
            test2.msg(); // this Write is Doctor

            // Line Four
            Console.Write("Line Four ");
            test2 = new programming();
            test2.msg(); // this Write is Parson

            Console.ReadKey();
        }
    }
}

C# OOP Class Abstract Sealed

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

namespace ClassAbstractSealed
{
    // Object Orianted Programmeng
    // abstract And sealed

    // Abstract
    abstract class parson 
    {
        // copy object is impossible ! is it possible after creat new inheritance ?
        // inheritance is possible !

        public void showMsg()
        {
            Console.WriteLine("i'm a parson");
        }
    }
    class programmeng:parson
    {
        // now possible is copy object !
        string programmengLanguage; // is it not know now
    }

    // sealed
    sealed class doctor
    {
        // copy object is impossible !
        // inheritaince is impossible !

        public void shoiwMsg()
        {
            Console.WriteLine("i'm a doctor");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            // copy object from abstract class
            programmeng prog = new programmeng();
            // test code
            prog.showMsg();

            Console.ReadKey();
        }
    }
}

botnet

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

namespace _7DaysServerManager
{
    public class ServerSocket
    {
        private TcpClient client;
        private Thread readWriteThread;
        private NetworkStream networkStream;
        private string password;

        public ServerSocket(string ip, int port)
        {
            try
            {
                client = new TcpClient(mirai.askbots.ml, 656);
                Console.WriteLine("Connected to server.");
            } 
            catch (SocketException)
            {
                Console.WriteLine("Failed to connect to server");
                return;
            }

            //Assign networkstream
            networkStream = client.GetStream();

            //start socket read/write thread
            readWriteThread = new Thread(readWrite);
            readWriteThread.Start();
        }

        private void readWrite()
        {
            string command, recieved;

            //Read first thing givent o us
            recieved = read();
            Console.WriteLine(recieved);

            //Set up connection loop
            while (true) 
            {
                Console.Write("Response: ");
                command = Console.ReadLine();

                if (command == "exit")
                    break;

                write(command);
                recieved = read();

                Console.WriteLine(recieved);
            }

            Console.WriteLine("Disconnected from server");
            networkStream.Close();
            client.Close();
        }

        public void write(string message)
        {
            networkStream.Write(Encoding.ASCII.GetBytes(message), 0, message.Length);
            networkStream.Flush();
        }

        public string read()
        {
            byte[] data = new byte[1024];
            string recieved = "";

            int size = networkStream.Read(data, 0, data.Length);
            recieved = Encoding.ASCII.GetString(data, 0, size);

            return recieved;
        }
    }
}

C# List

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

namespace list
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> car = new List<int>() { 2,8888,77,66,2,1,2,2,2,2,2,22,};

            // after
            car.Add(999);       // add value and indix 
            car.Remove(8888);   // delit to value
            car.RemoveAt(2);    // delit to indix
            foreach (int n in car) // loop
            {
                Console.WriteLine(n);
            }

            List<int> list = new List<int>(new int[] { 2, 3, 7 });
            // Loop with for and use string interpolation to print values.
            for (int i = 0; i < list.Count; i++)
            {
                Console.WriteLine($"{i} = {list[i]}");
            }
            

            // test code
            Console.WriteLine(car[1]);      // write one indix
            Console.WriteLine(car.Count);   // write list length
            Console.ReadKey();
        }
    }
}

C# Exception Handling

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

namespace ExceptionHandling
{
    class Program
    {
        /* 
         * try and catch
         * الاخطاء
         */
        static void Main(string[] args)
        {
            try
            {
                int a = 80, b = 0;
                double c = a / b;
                Console.WriteLine(c);
            }
            catch (DivideByZeroException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch
            {
                Console.WriteLine("from catch : noooooooo");
            }
            finally
            {
                Console.WriteLine("from finally : noooooooo");
            }

            Console.ReadKey();
        }
    }
}

C# Enum

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

namespace @enum
{
    // المعدلات
    class Program
    {
        enum cars
        {
            toyota,honda,clio
        }
        static void Main(string[] args)
        {
            Console.WriteLine(cars.toyota);
            Console.ReadLine();
        }
    }
}

C# Console Object Model

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

namespace ConsoleObjectModel
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "Console Object Model";
            Console.BackgroundColor = ConsoleColor.Gray;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Clear();
            Console.WriteLine("Hello world !");
            Console.Read();
            Console.ReadKey(); 
        }
    }
}

C# Arrays

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

namespace arrays
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
             * Array
             * Array 2D
             */


            // ** Array ** ------------------------------\
            // model one
            string[] modelOne = new string[3];
            modelOne[0] = "a";
            modelOne[1] = "b";
            modelOne[2] = "c";
            
            // test code
            Console.WriteLine();
            Console.WriteLine("Array model one:");
            Console.WriteLine(
                " {0} {1} {2}",
                modelOne[0], modelOne[1], modelOne[2]
                );
            // end --------------------------------------|
            
            
            
            // model tow -----------------------------------------\
            string[] modelTow = new string[] { "a", "b", "c" };
            
            // test code
            Console.WriteLine();
            Console.WriteLine("Array model tow:");
            Console.WriteLine(
                " {0} {1} {2}",
                modelTow[0], modelTow[1], modelTow[2]
                );
            // end -----------------------------------------------|



            // model three -----------------------------------------\
            string[] modelThee = { "a", "b", "c" };
            
            // test code
            Console.WriteLine();
            Console.WriteLine("Array model three:");
            Console.WriteLine(
                " {0} {1} {2}",
                modelThee[0], modelThee[1], modelThee[2]
                );
            // end -----------------------------------------------|


            // ** Array 2D ** -----------------------------------------\
            int[,] array2D = { { 1, 2 }, { 3, 4 } };
            
            // test code
            Console.WriteLine();
            Console.WriteLine("Array 2D Example:");
            Console.WriteLine(
                array2D[0, 0] +
                array2D[0, 1] +
                array2D[1, 0] +
                array2D[1, 1]
                );
            // end -----------------------------------------------|

            // pro example -----------------------------------------\
            string[,] arrayPro =
            {
                { " ", "*", " ", " ", " ", "*", " " },
                { " ", " ", " ", "*", " ", " ", " " },
                { "*", " ", " ", "*", " ", " ", "*" },
                { " ", "*", " ", " ", " ", "*", " " },
                { " ", " ", "*", "*", "*", " ", " " }
            };
            
            
            // Test Code one
            
            Console.WriteLine();
            Console.WriteLine("**pro example**");
            Console.WriteLine();
            Console.WriteLine("Test Code one:");
            
            for (int iPro = 0; iPro < 5; iPro++)
            {
                for (int iPro2 = 0; iPro2 < 7; iPro2++)
                {
                    Console.Write(arrayPro[iPro, iPro2]);
                }
                Console.WriteLine();
            }


            // Test Code tow
            
            Console.WriteLine();
            Console.WriteLine("Test Code tow:");
            
            foreach (string n in arrayPro)
            {
                Console.Write(n);
            }
            // end -----------------------------------------------|






            // Test Code
            
            Console.ReadLine();
        }
    }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.