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

Compile and Execute C# Sharp Online

using System.IO;
using System;

class Program
{
    static void Main()
    {
     /*int [] numbers = new int [5];
      
     // numbers [0] = 4;
      //numbers [1] = 8;
      //numbers [2] = 15;
      //numbers [3] = 16;
      numbers [4] = 23;
      
      //Console.WriteLine(numbers[1]);
      Console.WriteLine(numbers.Length);
      Console.ReadLine();
      int [] numbers = new int []{4, 8, 15, 16, 23, 42};*/
      string[] names = new string [] {"Eddie", "Alex", "Micheal", "David Lee"};
     /* for (int i =0; i < names.Length; i++)
      {
          Console.WriteLine(names[i]);
      }
       Console.ReadLine();*/
       foreach ( string name in names)
       {
        Console.WriteLine(name);   
       }
       Console.ReadLine();
       }
      }

https://pt.stackoverflow.com/q/46086/101

using static System.Console;

public class Program {
	public static void Main() {
		var x = 1;
		WriteLine(x == 1 || x == 2);
		WriteLine(x == 1 || x != 2);
		WriteLine(x != 1 || x != 2);
		WriteLine(x == 1 && x == 2);
		WriteLine(x == 1 && x != 2);
		WriteLine(x != 1 && x != 2);
		WriteLine(x == 3 || x == 2);
		WriteLine(x == 3 || x != 2);
		WriteLine(x != 3 || x != 1);
		WriteLine(x == 3 && x == 2);
		WriteLine(x == 3 && x != 2);
		WriteLine(x != 3 && x != 2);
	}
}

//https://pt.stackoverflow.com/q/46086/101

Jagged Array Example

using System.IO;
using System;

class Program
{
    int[] factors;
    int[] count;
    int[][] jagg;
    
    static void Main()
    {
        Program pg = new Program();
        
        pg.factors = new int[3] {100, 200, 300};
        pg.count = new int[3] {3, 4, 5};
        
        pg.MakeJaggedArray(pg.factors, pg.count);
        pg.ShowJaggedArray(pg.jagg);
        Console.WriteLine();
        pg.ShowJaggedSingle(pg.jagg, 0);
    }
    
    void MakeJaggedArray(int[] myfactors, int[] mycount)
    {
        jagg = new int[myfactors.Length][];
        
        for(int i=0; i < myfactors.Length; i++)
        {
            jagg[i] = new int[mycount[i]];
            
            for(int j=0; j< mycount[i]; j++)
            {
                jagg[i][j] = myfactors[i] + 3 * j;
            }
        }
    }
    
    void ShowJaggedArray(int[][] myJagg)
    {
        for(int i=0; i < myJagg.Length; i++)
        {
            for(int j=0; j< myJagg[i].Length; j++)
            {
                Console.Write("jagg[{0}][{1}] : ",i,j); 
                Console.WriteLine(myJagg[i][j]);
            }
        }
    }
    
    void ShowJaggedSingle(int[][] myJagg, int index)
    {
        for(int i=0; i < myJagg.Length; i++)
        {
            Console.Write("jagg[{0}][",i);
            for(int j=0; j< myJagg[i].Length; j++)
            {
                Console.Write(myJagg[i][j] + "\t");
            }
            Console.WriteLine("\b]");
        }
    }
}

Matchstick

using System.IO;
using System;

class Program
{
    static void Main()
    {
        int s=21,user,computer,n=0;
        while(s>=1)
        {
            if(s==1)
            {   Console.WriteLine("computer won the game");
                
                break;
            }
            
            user= Convert.ToInt32(Console.ReadLine());
            
            if(user>4)
            {
                Console.WriteLine("invalid");
            }
            else
            {
                Console.WriteLine("user's turn= "+user);
                computer=5-user;
                Console.WriteLine("computer's turn= "+computer);              
                n+=(user+computer);
            }
            s=21-n;
        }
    }
}

Unity - class LoadScene

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class LoadScene : MonoBehaviour
{

    public void loadScenePerID(int sceneID)
    {
        SceneManager.LoadScene(sceneID);
    }

    public void loadScenePerName(string sceneName)
    {
        SceneManager.LoadScene(sceneName);
    }

    public void quitGame()
    {
        Application.Quit();
    }
}

0010

using System.IO;
using System;

class Program
{
    static void Main()
    {
        int a = 7;
            double c = 0;
            for (double i = 2; i < a; i++)
            {
                c = 1+(1/i);
                Console.WriteLine(c);
            }

           
            Console.ReadKey();
    }
}

0011

using System.IO;
using System;

class Program
{
    static void Main()
    {
        int a = 2;
            int b = 5;

            int c = 0;
            for (int i = 0; i < b; i++)
            {
                c = (a*a + (a+i))*a+((2*i)*2);
                Console.WriteLine(c);
            }

           
            Console.ReadKey();
    }
}

my first project

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

namespace ConsoleApp1
{
    class mono
        {
        static void Main(string[] args)
        {
            console.WriteLine("hellovmart                  "); 
                        Console.ReadKey();
        }
    }
}

Compile and Execute C# Sharp Online

using System;

namespace PolymorphismApplication {
   abstract class Shape {
      public abstract int area();
   }
   
   class Rectangle:  Shape {
      private int length;
      private int width;
      
      public Rectangle( int a = 0, int b = 0) {
         length = a;
         width = b;
      }
      public override int area () { 
         Console.WriteLine("Rectangle class area :");
         return (width * length); 
      }
   }
   class RectangleTester {
      static void Main(string[] args) {
         Rectangle r = new Rectangle(10, 7);
         double a = r.area();
         Console.WriteLine("Area: {0}",a);
         Console.ReadKey();
      }
   }
}

0003

using System.IO;
using System;

class Program
{
    static void Main()
    {
        int a = 10;
            int b = 5;
            int[] tver = new int[a];
            Random r = new Random();
            for (int i = 0; i < a; i++)
            {
                tver[i] = r.Next(1, 9);
                if (tver[i] < b)
                    Console.WriteLine(tver[i]);
            }

                    Console.ReadKey();
    }
}

Advertisements
Loading...

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