interface ISpeaking {
public void Speak();
}
public class Dog: ISpeaking {
public void Speak() => Console.WriteLine("Гав!");
}
public class Cat: ISpeaking {
public void Speak() => Console.WriteLine("Мяу!");
}
public static void Main() {
ISpeaking[] speakers = new ISpeaking[] {new Cat(), new Dog()};
foreach(ISpeaking speaker in speakers)
speaker.Speak();
}
static void PrintAll(string[] array) {
foreach(var e in array)
Console.WriteLine(e);
}
static void PrintAll(List<string> list) {
foreach(var e in list) { // Дублирование!
Console.WriteLine(e);
}
// Можно использовать и для string[], и для List<string>, и даже для того, о чём мы ещё не знаем!
static void PrintAll(IEnumerable<string> collection) {
foreach(var e in collection) {
Console.WriteLine(e);
}
}
Чем Progressive Web Application уступают нативным мобильным приложениям?
Напрямую обращаться к базе данных в Xamarin.Forms я так понимаю тоже может быть не хорошим вариантомНет. Это вполне ок, в случае sqlite. Зачем тут вообще PHP в промежутке?
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net5.0/Demo.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
}
]
}
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "shell",
"args": [
"build",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
var json = "{\"id\":1,\"number\":42,\"bagGUID\":null}";
var data = JsonSerializer.Deserialize<Barcode>(json);
Console.WriteLine(data!.ToString()); // выведет "Barcode { Id = 1, Number = 42, BagGuid = }"
record Barcode
{
[JsonPropertyName("id")]
public int Id { get; init; }
[JsonPropertyName("number")]
public int Number { get; init; }
[JsonPropertyName("bagGUID")]
public Guid? BagGuid { get; init; }
}