namespace Task3
{
class MainClass
{
public static void Main(string[] args)
{
const string expression = "((a + b)² - (a² + 2ab)) / b²";
Console.WriteLine(expression);
var a = GetDouble("a");
var b = GetDouble("b");
if (b == 0)
{
Console.WriteLine("Invalid value of b");
return;
}
var result = EvaluateExpression(a, b);
Console.WriteLine(@$"a = {a};
b = {b};
{expression} = {result}");
}
private static double GetDouble(string varName)
{
Console.WriteLine($"Enter the number '{varName}', using a '.' for fractional part");
double value;
while (!double.TryParse(Console.ReadLine(), NumberStyles.Float | NumberStyles.Integer, CultureInfo.InvariantCulture, out value))
Console.WriteLine("Wrong number format, please try again");
return value;
}
private static double EvaluateExpression(double a, double b) =>
(Math.Pow(a + b, 2) - (Math.Pow(a, 2) + 2 * a * b)) / Math.Pow(b, 2);
}
}
данный участок был взят из другого рабочего проекта
Чтобы там ещё какаято СУБД от Microsoft была запущена.
var date = "03.09.2020 5:00:00";
var format = "dd.MM.yyyy H:mm:ss";
var dt = DateTime.ParseExact(date, format, CultureInfo.InvariantCulture);
dt.Dump();
var date = "03.09.2020 5:00:00";
const string format = "dd.MM.yyyy H:mm:ss";
if (DateTime.TryParseExact(date,
format,
CultureInfo.InvariantCulture,
DateTimeStyles.None,
out var dt)
)
{
dt.Dump();
}
if not request.json:
print(request.json)
abort(404)
var httpClient = new HttpClient();
var request = new
{
login = "admin",
password = "12345"
};
var jsonString = JsonSerializer.Serialize(request);
var response = await httpClient.PostAsync(url, new StringContent(jsonString))
var contentString = await response.Content.ReadAsStringAsync();
var result = JsonDocument.Parse(contentString);
public Exception CreateException([CallerLineNumber] int line = 0) => new Exception("This exception created at line " +line);