C# WebClient Encoding

Description

WebClient Encoding Gets and sets the Encoding used to upload and download strings.

Syntax

WebClient.Encoding has the following syntax.


public Encoding Encoding { get; set; }

Example

Gets and sets the Encoding used to upload and download strings.


//w  w w . j av  a  2 s .  c  om
using System;
using System.Net;
using System.Net.Sockets;

public class Example
{
   public static void Main()
   {
        string data = "myData= 50";
        WebClient client = new WebClient ();

        client.Encoding = System.Text.Encoding.UTF8;

        string reply = client.UploadString ("http://yourserver.com", data);

        Console.WriteLine (reply);
    
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient