Вопрос: как мне правильно спроектировать таблицу для связей между этими товарами. Чтобы каждый из этих товаров ссылался друг на друга?
CREATE TABLE groups_of_goods (
group_id BIGINT UNSIGNED NOT NULL,
product_id BIGINT UNSIGNED NOT NULL,
PRIMARY KEY (group_id, product_id),
FOREIGN KEY fk_product (product_id) REFERENCES product (product_id)
);x и y это «радиусы» ромба. Есть координаты центра (cx, cy), или, удобнее, (0, 0) – понятны координаты вершин ромба: (-x, 0), (0, -y), (x, 0), (0, y) (по часовой стрелке).(0 + 2x, 0) (центр).(0 + x, 0 + y).class Ret
{
public Ret()
{
Words = new List<string>();
}
public List<string> Words { get; set; }
}class RequestData
{
public RequestData()
{
Ret = new Ret();
}
[JsonPropertyName("ret")]
public Ret Ret { get; set; }
}RequestData rd = new RequestData();
rd.Ret.Words.Add("Hello");
rd.Ret.Words.Add("World!");var json = JsonSerializer.Serialize(rd);
var data = "0, 1.1, 1.2, 1.3, name, true";
var myClass = MyClass.Parse(data);
MyClass.SeeChanges(myClass);public class MyClass
{
private int Id { get; set; }
private double X { get; set; }
private double Y { get; set; }
private double Z { get; set; }
private string Name { get; set; }
private bool Active { get; set; }
public static MyClass Parse(string data)
{
var myClass = new MyClass();
var properties = data.Split(',');
var props = myClass.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Public
| BindingFlags.Instance | BindingFlags.Static);
for (int i = 0; i < props.Length; i++)
{
var prop = props[i];
var type = prop.PropertyType;
prop.SetValue(myClass, Convert.ChangeType(properties[i], type, CultureInfo.InvariantCulture));
}
return myClass;
}
public static void SeeChanges(MyClass myClass)
{
var props = myClass.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Public
| BindingFlags.Instance | BindingFlags.Static);
foreach (var prop in props)
{
Debug.WriteLine("{0} = {1}", prop.Name, prop.GetValue(myClass, null));
}
}
}
CreateHostBuilder() - это метод, который объявлен ниже, он возвращает IHostBuilderIHost
char[] notAllowedSymbols = { '!', '#', '$', '%', '&', '(', ')', '*', ',', '+', '-' };массив[индекс]
var firstChar = notAllowedSymbols[0]; // '!'private static bool IsValid(string password)
{
char[] notAllowedSymbols = { '!', '#', '$', '%', '&', '(', ')', '*', ',', '+', '-' };
for (int i = 0; i < notAllowedSymbols.Length; i++)
{
if (password.Contains(notAllowedSymbols[i]))
{
return false;
}
}
return true;
} public abstract class Transport {
public int MaxSpeed { get; private set; }
public Transport(int maxSpeed) {
MaxSpeed = maxSpeed;
}
public string Run(int speed)
=> $"Скорость движения транспорта {(speed <= MaxSpeed ? "в пределах нормы" : "выше максимальной")}";
}
public class Car : Transport {
public Car() : base(300) {}
}
public class Bike : Transport {
public Bike() : base(40) {}
}