ASP.NET Tutorial/Development/Encoding — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 15:30, 26 мая 2010

Get bytes or chars (C#)

<%@ Page %>
<script language="C#" runat="server">
  private void Page_Load(object sender, System.EventArgs e)
  {
    int i;
    Byte[] myBytes = System.Text.Encoding.ASCII.GetBytes("Hello World");
    for (i=0;i<myBytes.Length;i++)
    {
      Response.Write(myBytes[i].ToString() + " ");
    }
    char[] myChars=System.Text.Encoding.ASCII.GetChars(myBytes);
    string myString=new string(myChars);
    Response.Write("<BR>" + myString);
    
  }
</script>
<html>
  <body>
    <form id="form1" method="post" runat="server">
    </form>
  </body>
</html>


Get bytes or chars (VB)

<%@ Page %>
<script language="vb" runat="server">
  Sub Page_Load(sender As Object, e As EventArgs)
    Dim i As Integer
    Dim myBytes As Byte() = System.Text.Encoding.ASCII.GetBytes("Hello World")
    For i=0 to myBytes.Length-1
      Response.Write(myBytes(i).ToString() & " ")
    Next i
    Dim myChars as Char() = System.Text.Encoding.ASCII.GetChars(myBytes)
    Dim myString as String = New String(myChars)
    Response.Write("<BR>" & myString)
  End Sub
</script>
<html>
  <body>
    <form id="form1" method="post" runat="server">
    </form>
  </body>
</html>