using System;namespace CSDN_Exp2
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
string str="xxxxyyyyyxyyx"; //想多少个就多少个
Class1 myclass=new Class1();
myclass.StrAppend(str); }
public void StrAppend(string strsource)
{
int k=strsource.Length;
char[] target=new char[k];
for(int i=0;i<k;i++)
{
if(strsource[i]=='x' || strsource[i]=='X')
{
target[i]='0';
}
if(strsource[i]=='y' || strsource[i]=='Y')
{
target[i]='1';
}
}
Console.Write(target);
Console.WriteLine();
}
}
}
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
string str="xxxxyyyyyxyyx"; //想多少个就多少个
Class1 myclass=new Class1();
myclass.StrAppend(str); }
public void StrAppend(string strsource)
{
int k=strsource.Length;
char[] target=new char[k];
for(int i=0;i<k;i++)
{
if(strsource[i]=='x' || strsource[i]=='X')
{
target[i]='0';
}
if(strsource[i]=='y' || strsource[i]=='Y')
{
target[i]='1';
}
}
Console.Write(target);
Console.WriteLine();
}
}
}
bit |= (byte)(bits[i] << (7 - i)); // 将bits[i] 左移7位,
// i = 0 时bits[i] << (7 - i)等于 10000000
}MessageBox.Show(bit.ToString()); // bit = 170