Files
s7netplus/S7.Net/Types/Byte.cs
Thomas Ze 7cedec5909 - fix data type converting
- add new string string data type
2018-03-18 21:26:22 +01:00

34 lines
841 B
C#

using System;
namespace S7.Net.Types
{
/// <summary>
/// Contains the methods to convert from bytes to byte arrays
/// </summary>
public static class Byte
{
/// <summary>
/// Converts a byte to byte array
/// </summary>
public static byte[] ToByteArray(byte value)
{
return new byte[] { value }; ;
}
/// <summary>
/// Converts a byte array to byte
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
public static byte FromByteArray(byte[] bytes)
{
if (bytes.Length != 1)
{
throw new ArgumentException("Wrong number of bytes. Bytes array must contain 1 bytes.");
}
return bytes[0];
}
}
}