-7
測試用例:字符串編碼程序
banagalore (of type String)
預期輸出:
{30,20,21,92,20,80,32,31,02}
我已經轉換他們使用C#爲ASCII,現在我不能夠將它們轉換成序列,請建議一些想法。
代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
Console.WriteLine("Enter The String ");
string str = Console.ReadLine();
byte[] b = Encoding.ASCII.GetBytes(str);
foreach (var item in b)
{
Console.WriteLine(item);
}
}
}
}
ASCII?你能詳細說一下嗎? – 2014-10-20 14:44:20
只需要將字符串轉換爲該序列,我有上面提到的測試用例之一。我認爲邏輯必須將字符串中的每個字符轉換爲ASCII值,然後找出必須做什麼,我陷入困境之後 – Vinodh 2014-10-20 14:50:32
SO並不是真正解決難題的地方 - 當找到什麼操作將「banagalore」轉換爲「 {30,20,21,92,20,80,32,31,02}「可能有趣,但不適合SO。 (即,在我知道的任何編碼中,它顯然不是字符代碼) – 2014-10-20 14:50:47