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

dsfsd

using System.IO;
using System;

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

Compile and Execute C# Sharp Online

using System;
using System;

class Program
{
    static void Main()
    {
        int i = 29;
        
        Console.WriteLine(i);
        Console.ReadLine();
    }
}

Yogita C# practice

using System.IO;
using System;

class Program
{
    static void Main()
    {
        int i, count, k=0, l=1, m=0;
            Console.WriteLine(k);
            Console.WriteLine(l);
            
            For (i=0; i<=count; i++)
            {
                m=k+l;
                Console.WriteLine(m);
                k=l;
                l=m;
            }
            Console.ReadLine();
    }
}

numerosPrimos

using System.IO;
using System;


 public class modulo
    {
        public static void Main()
        {
            
            int n,divisor;
            bool esPrimo;
            
            esPrimo=true;
            n=30;
            divisor=n/2;
            
            while(n!=1){
                while(divisor!=1&&esPrimo){
                    if(n%divisor==0){
                        esPrimo=false;
                    }
                    divisor--;
                
                }
                if(esPrimo){
                    System.Console.WriteLine(n);
                }
                n--;
                esPrimo=true;
            }
        }
    }

tttt

using System.IO;
using System;

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

Arrays

using System.IO;
using System;

class Program
{
    static void Main()
    {
        ParamArray pa = new ParamArray();

        int total = pa.GetValues(1265, 8978, 8713, 123688);
        Console.WriteLine("Sum of values: {0}", total;        
        Console.ReadLine();
    }
}

class ParamArray
{
    public int GetValues(params int[] arr)
    {
        int sum;
        foreach(int i in arr)
        {
            sum += i;
        }
        return sum;
    }   
}

Encapsulation

using System.IO;
using System;

class Rectangle
    {
      public double length, width;
      
      double GetArea()
      {
         return length * width;
      }
      public void Info()
      {
         Console.WriteLine("Length: {0}\nWidth: {1}", length, width);
         Console.WriteLine("Result: {0}", GetArea());
         Console.WriteLine("==========");
      }
   }
   
   class Square
   {
        double side;
        
        public Square(double s)
        {
            side = s;
        }
        double CountArea()
        {
            return side * side;    
        }
        public void Display()
        {
            Console.WriteLine("Side: {0}\nArea: {1}", side, CountArea());
            Console.WriteLine("==========");
        }
   }
   
   class Circle
   {
        const double pi = 3.14;
        double radius;
    
        public void UserInput()
        {
            Console.WriteLine("Enter radius:");
            radius = Convert.ToDouble(Console.ReadLine());
        }
        double Result()
        {
            return pi * radius * radius;
        }
        public void Details()
        {
            Console.WriteLine("Radius: {0}\nResult:{1}", radius, Result());
            Console.WriteLine("==========");
        }
   }
   
   class Program
   {
      static void Main(string[] args)
      {
         Rectangle r = new Rectangle();
         r.length = 5.8;
         r.width = 7.8;
         r.Info();
         
         Square s = new Square(5.89);
         s.Display();
         
         Circle c = new Circle();
         c.UserInput();
         c.Details();
         
         Console.ReadLine();
      }
   }

aaaa

using System.IO;
using System;

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

webservices

public string Post(string methodName, string jsonParas)
    {
      string strURL = Url + "/" + methodName;

      //创建一个HTTP请求 
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
      //Post请求方式 
      request.Method = "POST";
      //内容类型
      request.ContentType = "application/x-www-form-urlencoded";

      //设置参数,并进行URL编码 
      //虽然我们需要传递给服务器端的实际参数是JsonParas(格式:[{\"UserID\":\"0206001\",\"UserName\":\"ceshi\"}]),
      //但是需要将该字符串参数构造成键值对的形式(注:"paramaters=[{\"UserID\":\"0206001\",\"UserName\":\"ceshi\"}]"),
      //其中键paramaters为WebService接口函数的参数名,值为经过序列化的Json数据字符串
      //最后将字符串参数进行Url编码
      string paraUrlCoded = System.Web.HttpUtility.UrlEncode("paramaters");
      paraUrlCoded += "=" + System.Web.HttpUtility.UrlEncode(jsonParas);

      byte[] payload;
      //将Json字符串转化为字节 
      payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
      //设置请求的ContentLength  
      request.ContentLength = payload.Length;
      //发送请求,获得请求流 

      Stream writer;
      try
      {
        writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
      }
      catch (Exception)
      {
        writer = null;
        Console.Write("连接服务器失败!");
      }
      //将请求参数写入流
      writer.Write(payload, 0, payload.Length);
      writer.Close();//关闭请求流

      String strValue = "";//strValue为http响应所返回的字符流
      HttpWebResponse response;
      try
      {
        //获得响应流
        response = (HttpWebResponse)request.GetResponse();
      }
      catch (WebException ex)
      {
        response = ex.Response as HttpWebResponse;
      }

      Stream s = response.GetResponseStream();

      //服务器端返回的是一个XML格式的字符串,XML的Content才是我们所需要的Json数据
      XmlTextReader Reader = new XmlTextReader(s);
      Reader.MoveToContent();
      strValue = Reader.ReadInnerXml();//取出Content中的Json数据
      Reader.Close();
      s.Close();

      return strValue;//返回Json数据
    }

test

using System.IO;
using System;

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

Advertisements
Loading...

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