forked from S7NetPlus/s7netplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathByte.cs
33 lines (30 loc) · 841 Bytes
/
Byte.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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];
}
}
}