本文整理汇总了C#中System.Text.UTF8Encoding.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# System.Text.UTF8Encoding.GetLength方法的具体用法?C# System.Text.UTF8Encoding.GetLength怎么用?C# System.Text.UTF8Encoding.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.UTF8Encoding
的用法示例。
在下文中一共展示了System.Text.UTF8Encoding.GetLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoTestLocalMessageBroadcast
public void DoTestLocalMessageBroadcast()
{
Console.Write("What's your name: ");
string name = Console.ReadLine();
Console.Write("Which channel (0-9) do you want to use: ");
char input = Console.ReadKey(true).KeyChar;//.ReadLine();
while ( input != '0' && input != '1' && input != '2' && input != '3' && input != '4' && input != '5' && input != '6' && input != '7' && input != '8' && input != '9' ) {
input = Console.ReadKey(true).KeyChar;
}
Console.WriteLine("\n");
string channel = input.ToString();
joinedDelegate = BroadcastMessagePartnerJoinedCallback;
leftDelegate = BroadcastMessagePartnerLeftCallback;
receivedDelegate = BroadcastMessageReceivedCallback;
UInt32 hLocalMessageBroadcastPartner = CreateLocalMessageBroadcastPartner(
"BroadcastTest/channel" + channel,
name,
IntPtr.Zero,
Marshal.GetFunctionPointerForDelegate(joinedDelegate),
Marshal.GetFunctionPointerForDelegate(leftDelegate),
Marshal.GetFunctionPointerForDelegate(receivedDelegate)
);
if ( hLocalMessageBroadcastPartner > 0 ) {
try {
Console.WriteLine("");
Console.WriteLine("Welcome " + name + "! You can talk to the others on channel " + channel + " by typing s, then your message and pressing <enter>");
input = Console.ReadKey(true).KeyChar;//.ReadLine();
while ( input != 'q' ) {
if ( input == 's' ) {
Console.Write( name + " says: ");
string s = Console.ReadLine();
byte[] stringBytes = new System.Text.UTF8Encoding().GetBytes(s);
BroadcastMessage( hLocalMessageBroadcastPartner, stringBytes, (UInt32)(stringBytes.GetLength(0)) );
}
input = Console.ReadKey(true).KeyChar;
}
}
finally {
if ( DestroyLocalMessageBroadcastPartner(hLocalMessageBroadcastPartner) ) {
Console.WriteLine( "SUCCESSFULLY destroyed LocalMessageBroadcast Partner" );
}
else {
Console.WriteLine( "FAILED to destroy LocalMessageBroadcast Partner" );
}
}
}
else {
Console.WriteLine( "CreateLocalMessageBroadcastPartner FAILED!!!" );
}
Console.WriteLine( "\nPress 'q' again to really quit..." );
char input2 = Console.ReadKey(true).KeyChar;//.ReadLine();
while ( input2 != 'q' ) {
}
//Thread.Sleep(8000);
}