This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Data; | |
using Microsoft.Data.SqlClient; | |
class Program | |
{ | |
static void Main() | |
{ | |
Console.OutputEncoding = System.Text.Encoding.UTF8; | |
// запрашиваем у пользователя данные для подключения к БД, хранить в коде не безопасно |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dotnet add package Newtonsoft.Json | |
using Microsoft.Data.SqlClient; | |
using Newtonsoft.Json; | |
using Z.Dapper.Plus; | |
using System.Reflection.Emit; | |
using System.Reflection; | |
namespace JSONToDatabase | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Threads | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
SimpleThreadDemo(); | |
// CustomThreadDemo(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; // основное пространство имён для работы с сетевыми адресами и протоколами | |
using System.Net.Sockets; // пространство имён для работы с сокетами | |
using System.Text; // пространство имён для работы с кодировками | |
class Server // класс реализует серверную логику | |
{ | |
private const int DEFAULT_BUFLEN = 512; // задаёт размер буфера для получения данных | |
// если нужно работать с большим количеством данных, рекомендуется использовать буферы от 4 КБ до 64 КБ (размер, с которым обычно работают сетевые приложения) | |
// если данные небольшие и ожидается, что они будут приходить в небольших объёмах, можно использовать буфер 512 байт или даже меньше | |
private const string DEFAULT_PORT = "27015"; // указывает порт, на котором сервер будет прослушивать подключения |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
using System.Net.Sockets; | |
using System.Text; | |
class Client | |
{ | |
private const int DEFAULT_BUFLEN = 512; | |
private const string DEFAULT_PORT = "27015"; | |
static void Main() |