secondary commit

This commit is contained in:
Stoyan Zlatev
2023-08-25 15:56:36 +02:00
parent 83359fc4d7
commit 56ed57f15b
+21 -18
View File
@@ -2,35 +2,38 @@
{
using CommonMessurementUnits;
using Newtonsoft.Json;
using System;
public class Program
{
public static void Main(string[] args)
{
int x = 3;
Console.WriteLine($"From Int32: {x}");
byte[] xb = x.GetBytes();
Console.WriteLine(string.Join("", xb.GetBits()));
Console.WriteLine(xb.ToHex());
long y = BitConverter.ToInt32(xb, 0);
Console.WriteLine(y);
Console.WriteLine($"Bits: {string.Join("", xb.GetBits())}");
Console.WriteLine($"Hex bytes: {xb.ToHex()}");
int y = BitConverter.ToInt32(xb, 0);
Console.WriteLine($"To Int32: {y}");
Console.WriteLine();
//var model = new TestClass
//{
// Flow = 1,
// Time = 15.56,
// Volume = 40,
// Pressure = 250000,
// Current = 130,
// Temperature = 21.9
//};
var model = new TestClass
{
Flow = 1,
Time = 15.56,
Volume = 40,
Pressure = 250000,
Current = 130,
Temperature = 21.9
};
//var modelJson = JsonConvert.SerializeObject(model, Formatting.Indented);
//var testModel = JsonConvert.DeserializeObject<TestClass>(modelJson);
var modelJson = JsonConvert.SerializeObject(model, Formatting.Indented);
var testModel = JsonConvert.DeserializeObject<TestClass>(modelJson);
//Console.WriteLine(modelJson);
//Console.WriteLine(JsonConvert.SerializeObject(testModel, Formatting.Indented));
Console.WriteLine($"To Json: {modelJson}");
Console.WriteLine($"From Json: {JsonConvert.SerializeObject(testModel, Formatting.Indented)}");
}
}