本文整理汇总了C#中System.Byte.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Byte.ToString方法的具体用法?C# Byte.ToString怎么用?C# Byte.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Byte
的用法示例。
在下文中一共展示了Byte.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
string data = "";
byte[] sendBytes = new Byte[1024];
byte[] rcvPacket = new Byte[1024];
UdpClient client = new UdpClient();
IPAddress address = IPAddress.Parse(IPAddress.Broadcast.ToString());
client.Connect(address, 8008);
IPEndPoint remoteIPEndPoint = new IPEndPoint(IPAddress.Any, 0);
Console.WriteLine("Client is Started");
Console.WriteLine("Type your message");
while (data != "q")
{
data = Console.ReadLine();
sendBytes = Encoding.ASCII.GetBytes(DateTime.Now.ToString() + " " + data);
client.Send(sendBytes, sendBytes.GetLength(0));
rcvPacket = client.Receive(ref remoteIPEndPoint);
string rcvData = Encoding.ASCII.GetString(rcvPacket);
Console.WriteLine("Handling client at " + remoteIPEndPoint + " - ");
Console.WriteLine("Message Received: " + rcvPacket.ToString());
}
Console.WriteLine("Close Port Command Sent"); //user feedback
Console.ReadLine();
client.Close(); //close connection
}
示例2: ClearFanCtrlData
/// <summary>
/// Clears all historical control data (i.e. power on/off) associated with a numbered fan.
/// </summary>
/// <param name="fanNumber">Numbered fan to clear historical data from.</param>
/// <returns>Asynchronous Processing Task.</returns>
public async Task ClearFanCtrlData(Byte fanNumber)
{
//Call Worker.
await RESTWorker("/MooseBox/API/v1.0/peripherals/fan/data/clear",
Method.DELETE,
restRequest => { restRequest.AddQueryParameter(ParamFanNumber, fanNumber.ToString()); });
}
示例3: CheckByte
public void CheckByte(Byte value, string format)
{
var parsed = Format.Parse(format);
var formatter = new StringFormatter(pool);
formatter.Append(value, parsed);
var result = formatter.ToString();
var clrResult = value.ToString(format, CultureInfo.InvariantCulture);
Assert.Equal(clrResult, result);
}
示例4: Main
static void Main(string[] args)
{
if (args.Length > 1)
throw new ArgumentException("Params : <[Port]>");
int servPort = (args.Length == 1) ? Int32.Parse(args[0]) : 2500;
TcpListener listner = null;
try
{
listner = new TcpListener(IPAddress.Any, servPort);
listner.Start();
Console.WriteLine("Waiting for a connection ..... ");
}
catch (SocketException e)
{
Console.WriteLine(e.ErrorCode + ":" + e.Message);
Environment.Exit(e.ErrorCode);
}
byte[] rcvBuffer = new Byte[BUFSIZE];
int byteRcv;
while (true)
{
Socket sock = null;
try
{
sock = listner.AcceptSocket();
Console.Write("Handling Client at " + sock.RemoteEndPoint + " : ");
int totalBytesEchoed = 0;
while ((byteRcv = sock.Receive(rcvBuffer, 0, rcvBuffer.Length, SocketFlags.None)) > 0)
{
string caps = Encoding.ASCII.GetString(rcvBuffer);
caps.ToUpper();
rcvBuffer = Encoding.ASCII.GetBytes(caps);
sock.Send(rcvBuffer, 0, byteRcv, SocketFlags.None);
totalBytesEchoed += byteRcv;
}
Console.WriteLine("Sent : " + rcvBuffer.ToString());
Console.WriteLine("Echoed {0} bytes.", totalBytesEchoed);
sock.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
sock.Close();
}
}
}
示例5: PowerFanCtrl
/// <summary>
/// Manually powers on/off a USB fan in the event it does not conflict with Fan Automation.
/// </summary>
/// <param name="fanNumber">Numbered fan to power on or off.</param>
/// <param name="powerOn">true to power fan; false to unpower.</param>
/// <returns>Asynchronous processing task.</returns>
public async Task PowerFanCtrl(Byte fanNumber, bool powerOn)
{
//Call Worker.
await RESTWorker("/MooseBox/API/v1.0/control/fan/power",
Method.PUT,
restRequest =>
{
restRequest.AddQueryParameter(ParamFanNumber, fanNumber.ToString());
restRequest.AddQueryParameter(ParamPowerOn, powerOn.ToString().ToLower());
});
}
示例6: ByteToStr
///<summary>The only valid input is a value between 0 and 15. Text returned will be 1-9 or a-f.</summary>
private static string ByteToStr(Byte byteVal) {
//No need to check RemotingRole; no call to db.
switch(byteVal) {
case 10:
return "a";
case 11:
return "b";
case 12:
return "c";
case 13:
return "d";
case 14:
return "e";
case 15:
return "f";
default:
return byteVal.ToString();
}
}
示例7: ToSqlString
/// <summary>
/// Converts the value of the specified nullable 8-bit unsigned integer to its equivalent SqlString representation.
/// </summary>
/// <param name="value">A nullable 8-bit unsigned integer.</param>
/// <returns>The SqlString equivalent of the nullable 8-bit unsigned integer value.</returns>
public static SqlString ToSqlString(Byte? value) { return value.HasValue ? value.ToString() : SqlString.Null; }
示例8: ToString
/// <summary>
/// Converts the value of the specified nullable 8-bit unsigned integer to its equivalent String representation.
/// </summary>
/// <param name="value">A nullable 8-bit unsigned integer.</param>
/// <returns>The String equivalent of the nullable 8-bit unsigned integer value.</returns>
public static String ToString(Byte? value) { return value.ToString(); }
示例9: ToSqlString
/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlString</c> value.</summary>
public static SqlString ToSqlString(Byte p) { return p.ToString(); }
示例10: ToSqlChars
/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlChars</c> value.</summary>
public static SqlChars ToSqlChars(Byte? p) { return p.HasValue? new SqlChars(p.ToString().ToCharArray()): SqlChars.Null; }
示例11: SCsendLEDarray
public void SCsendLEDarray(Byte[] ledStripArray)
{
if (this.comPortOpen)
{
arduinoBoard.WriteLine("99");
arduinoBoard.WriteLine(ledStripArray.ToString());
}
}
示例12: Rend
static public String Rend(Byte d)
{
return d.ToString();
}
示例13: SetLedBlinkPatternAsync
/// <summary>
/// Uses a feature report to set the blink pattern on the SuperMutt's LED.
///
/// Please note that when we create a FeatureReport, all data is nulled out in the report. Since we will only be modifying
/// data we care about, the other bits that we don't care about, will be zeroed out. Controls will effectively do the same thing (
/// all bits are zeroed out except for the bits we care about).
///
/// Any errors in async function will be passed down the task chain and will not be caught here because errors should be handled
/// at the end of the task chain.
///
/// The SuperMutt has the following patterns:
/// 0 - LED always on
/// 1 - LED flash 2 seconds on, 2 off, repeat
/// 2 - LED flash 2 seconds on, 1 off, 2 on, 4 off, repeat
/// ...
/// 7 - 7 iterations of 2 on, 1 off, followed by 4 off, repeat
/// </summary>
/// <param name="pattern">A number from 0-7. Each number represents a different blinking pattern</param>
/// <returns>A task that can be used to chain more methods after completing the scenario</returns>
async Task SetLedBlinkPatternAsync(Byte pattern)
{
var featureReport = EventHandlerForDevice.Current.Device.CreateFeatureReport(SuperMutt.LedPattern.ReportId);
var dataWriter = new DataWriter();
// First byte is always the report id
dataWriter.WriteByte((Byte) featureReport.Id);
dataWriter.WriteByte(pattern);
featureReport.Data = dataWriter.DetachBuffer();
await EventHandlerForDevice.Current.Device.SendFeatureReportAsync(featureReport);
rootPage.NotifyUser("The Led blink pattern is set to " + pattern.ToString(), NotifyType.StatusMessage);
}
示例14: IsLandingSquareEmpty
private Boolean IsLandingSquareEmpty(Byte startSquare, MoveDirection jumpDirection)
{
Boolean answer = false;
String start = startSquare.ToString() + jumpDirection.ToString().ToLower();
Byte landingSquare = JumpLandingSquareLookup[start];
UInt64 landingBitBoard = squareTable[landingSquare];
if ((emptySquares & landingBitBoard) != 0UL)
answer = true;
return answer;
}
示例15: CreateMoveFromJump
private Move CreateMoveFromJump(Byte index, MoveDirection direction)
{
String key = index.ToString() + direction.ToString().ToLower();
Byte landingSquare = JumpLandingSquareLookup[key];
Move move = new Move(index, landingSquare, true);
return move;
}