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

Conta.cs

using System.IO;
using System;

class Program
{
    static void Main()
    {
        class Conta
        {

        }
    }
}

Compile and Execute C# Sharp Online

using System.IO;
using System;

class Personne
{
    private string nom , prenom ;
    private int date ;
    private enum status = {"Marié","Célibataire","Veuf","Divorcé"};
    private char sexe ;
    private status st;
    
    public Personne(string n , string p, int d , char s , string st){
        this.nom = n;
        this.prenom = p;
        this.status = st;
        this.sexe = s;
    }
    
    public  getNom(){
        return(nom);
    }
    
    public getPrenom{
        return(prenom);
    }
    
    public getSexe(){
        return(sexe);
    }
    public getDate(){
        return(Date);
    }
    
    public getStatus(){
        return(status);
    }
    
    public setNom(string a){
        this.nom = a;
    }
    public setPrenom(string a){
        this.prenom = a;
    }
    
    public setSexe(char a){
        this.sexe = a;
    }
    public setStatus(string s){
        this.status=s;
    }
    
    
    
}

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

input

using System;
using System.IO;

class Program
{
    static void Main()
    {
       var json = File.ReadAllText(@"C:\input.txt");
       var a = new { serverTime = "", data = new object[] { } };
        
    }
}

Compile and Execute C# Sharp Online

using System;


class Program
  {
    static void Main()
    {
        int result1= Test(0);
        int result2= Test(50);
        int result3= Test(-1);
        
        Console.WriteLine(result1);
        Console.WriteLine(result2);
        Console.WriteLine(result3);
    }
    static int Test (int value)
    {
        if (value==0)
        {
            return -1;
        }
        else if (value <=10)
        {
            return 0;
        }
        else if (value <=100)
        {
            return 1;
        }
        else
        {
            return 2;
        }
        
        
  }
}

essam1

using System;
namespace Console_Array_NewSet

{
  class Program
  {
    static void main(string[]args){
 int []Array=new int[5];
 int i,j,Temp;
 for (i=0;i<Array.Length;i++)
 {
   Console.WriteLine("input a mount the element"+ i);
   Array[i]=int.Parse(Console.ReadLine());
 }
 for (i=0;i<Array.Length;i++){
   for(j=i+1;j<Array.Length;j++)
   {
     if (Array[i]>Array[j]){
       Temp=Array[i];
       Array[i]=Array[j];
       Array[j]=Temp;
     }
   }
 }
 foreach(int element in Array){
   Console.WriteLine("show element the Array in the new set:"+element);
 
   
 }
 }
    
  }
}

Compile and Execute C# Sharp Online

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            WebRequest myRequest = WebRequest.Create(@"https://tw.stock.yahoo.com/q/bc?s=1506");

            //Method選擇GET
            myRequest.Method = "GET";

            //取得WebRequest的回覆
            WebResponse myResponse = myRequest.GetResponse();

            //Streamreader讀取回覆
            StreamReader sr = new StreamReader(myResponse.GetResponseStream());

            //將全文轉成string
            string result = sr.ReadToEnd();

            //關掉StreamReader
            sr.Close();

            //關掉WebResponse
            myResponse.Close();
            System.Console.Write(result);
            Console.ReadLine();
            //搜尋頭尾關鍵字, 搜尋方法見後記(1)
            //int first = result.IndexOf("美元 = <em>");
            //int last = result.LastIndexOf("</em> 新台幣");

            //減去頭尾不要的字元或數字, 並將結果轉為string. 計算方式見後記(2)
            //string HTMLCut = result.Substring(first + 9, last - first - 9);
            //txtRate.Text = HTMLCut;
            
        }
    }
}

mine

using System;
using System.Collections.Generic;

public class MyClass
{
	public static void Main()
	{
		Random r = new Random();
		
		Console.WriteLine("Minecraft: What to do??? v1.0 \n");
		Console.WriteLine("Find out");
		Console.ReadKey();
		
		string[] choices = {"Slay some Creepers!", "Hunt down some cows!", "Go to the Nether!", "Brew some potions!"};
		Console.WriteLine(choices[r.Next(0, choices.Length)]);
		
		Console.ReadKey();
	}
}

Compile and Execute C# Sharp Online

using System.IO;
using System;

class Fibonacci
{

    public Fibonacci() {}
    
    public int getNumber(int number)
    {
        int fib=0;
        int x=0;
        int y=1;
        
        for (int i=0;i<number;i++)
        {
            fib=x+y;
            x=y;
            y=fib;
        }
        return fib;
    }

    static void Main()
    {
        Fibonacci f = new Fibonacci();
        Console.WriteLine(f.getNumber(10));
    }
}

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

public class Program {
	public static void Main() {
		var myClassObject = new MyClass() { Prop1 = "Teste", Prop2 = 10, FieldArray = new Field<dynamic>[2] { new Field<dynamic>("f1", "v1"), new Field<dynamic>("f1", 1) } };
	}
}

public class Field<TValue> {
    public string Name { get; set; }
    public TValue Value { get; set; }

    public Field() {}

    public Field(string name, TValue value) {
        this.Name = name;
        this.Value = value;
    }
}

public class MyClass {
    public string Prop1 { get; set; }
    public int Prop2 { get; set; }
    public Field<dynamic>[] FieldArray { get; set; }
}

//

Compile and Execute C# Sharp Online

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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            double pi = 3.14;
            int radius = 10  ;
            double result = pi * (radius * radius);

            Console.WriteLine("The area of the circle is {0} * ({1} * {1}) = {2} ", pi, radius, result);
            Console.ReadLine();

        }
    }
}

Advertisements
Loading...

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