Skip to content

Instantly share code, notes, and snippets.

static void LinqObj76()
{
var goods = ReadItems<Item>("goods.txt");
var prices = ReadItems<Cost>("prices.txt");
var result = goods
.GroupJoin(prices, g => g.Article, p => p.ItemArticle,
(g, p) => p.DefaultIfEmpty().Select(y => new {g.Country, y?.ShopName, y?.Price}))
.SelectMany(x => x)
.GroupBy(x => x.Country)
@amantix
amantix / LinqBegin54.cs
Created March 27, 2018 17:58
Left outer join
public static void LinqBegin54()
{
IEnumerable<string> a
= new[] {"AA", "B21", "A32", "VS", "S", "AAA"};
IEnumerable<string> b
= new[] {"B2", "BSS3", "AD6", "SSS"};
/*
var result =
a.GroupJoin(b, x => x[0], x => x[0],
@amantix
amantix / permutation.cs
Created February 26, 2018 11:14
Read names (lines of text) from text file, permute them and write result to another text file.
using System;
using System.Collections.Generic;
using System.IO;
namespace AssignmentRandomizer
{
class Program
{
static void Main()
{
@amantix
amantix / ConsoleGameEngine.cs
Last active April 5, 2023 13:19
Пример того, как можно реализовывать консольную игру. Показаны самые основы на примере перемещающейся собачки по нажатию стрелок на клавиатуре. Escape - выход.
using System;
using System.Diagnostics;
using System.Threading;
namespace ConsoleGame
{
class Program
{
public class At
{
<!DOCTYPE HTML>
<html>
<head>
<script>
function WebSocketTest()
{
if ("WebSocket" in window) {
report("WebSocket поддерживается вашим браузером!");
// Открыть WebSocket
var ws = new WebSocket("ws://localhost:8080");
using System;
using System.Net;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace WebTest
{
class Program
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="infoPane" />
<script>
var infoPane = document.getElementById('infoPane');
var report = function (msg) {
using System;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace WebTest
{
class Program
{
static void Main(string[] args)
@amantix
amantix / .gittattributes
Created September 8, 2017 12:17
Visual Studio .gitattributes
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
@amantix
amantix / .gitignore
Created September 8, 2017 12:16
Visual Studio .gitignore
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)