https://github.com/rx-j/ignite.binary
A simple class to get bytes from primitive data types and convert bytes to primitive data types.
https://github.com/rx-j/ignite.binary
csharp-library type-to-bytes
Last synced: 3 months ago
JSON representation
A simple class to get bytes from primitive data types and convert bytes to primitive data types.
- Host: GitHub
- URL: https://github.com/rx-j/ignite.binary
- Owner: RX-J
- Created: 2024-07-28T22:02:30.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-07-30T23:11:09.000Z (10 months ago)
- Last Synced: 2025-03-13T12:14:48.798Z (3 months ago)
- Topics: csharp-library, type-to-bytes
- Language: C#
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# The Ignite.Binary class extends the type byte[] and all primitive data types, whereby these can simply be converted into a byte[] and a byte[] into one of the primitive data types.
**The following data types can be used:**
- ```byte```
- ```ushort```
- ```uint```
- ```ulong```
---
- ```sbyte```
- ```short```
- ```int```
- ```long```
---
- ```nint```
- ```nuint```
---
- ```float```
- ```double```
- ```decimal```
---
- ```bool```
- ```char```
- ```string```
---**To call the ```Bytes``` function, you can use:**
```cs
var bytes_int = Ignite.Binary.Bytes (100); // bytes_int now contains the bytes of the int value "100", which looks like this: 100-0-0-0
var bytes_string = Ignite.Binary.Bytes ("Hello World!"); // bytes_string now contains the bytes of the int value "100", which looks like this: 72-101-108-108-111-32-87-111-114-108-100-33
```**To call the ```Convert``` class, you can use:**
```cs
var bytes_int = Ignite.Binary.Bytes (100);
var bytes_string = Ignite.Binary.Bytes ("Hello World!");var value_int = Ignite.Binary.Convert (bytes_int); // this will convert the byte array to an int
var value_string = Ignite.Binary.Convert (bytes_string); // this will convert the byte array to an string
```**To use the short form of the ```Bytes``` and ```Convert``` function you can write:**
```cs
using Ignite.Binary;var bytes_int = 100.Bytes ();
var bytes_string = "Hello World!".Bytes ();var value_int = bytes_int.Convert ();
var value_string = bytes_string.Convert ();
```**The format for ```Bytes``` is:**
```cs
Ignite.Binary.Bytes (VALUE);// or
using Ignite.Binary;
VALUE.Bytes ();
```**The format for ```Convert``` is:**
```cs
Ignite.Binary.Convert (BYTE_ARRAY);// or
using Ignite.Binary;
BYTE_ARRAY.Convert ();
```