using System;
using System.Runtime.InteropServices;
public class Program
{
[DllImport("kernel32.dll", ExactSpelling = true)]
private static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern bool EnableScrollBar(IntPtr hWnd, int wSBflags, int wArrows);
public static void Main(string[] args)
{
IntPtr handle = GetConsoleWindow();
EnableScrollBar(handle, 3, 3);
}
}
class Program
{
private const int MF_BYCOMMAND = 0x00000000;
public const int SC_CLOSE = 0xF060;
public const int SC_MINIMIZE = 0xF020;
public const int SC_MAXIMIZE = 0xF030;
public const int SC_SIZE = 0xF000;
[DllImport("user32.dll")]
public static extern int DeleteMenu(IntPtr hMenu, int nPosition, int wFlags);
[DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("kernel32.dll", ExactSpelling = true)]
private static extern IntPtr GetConsoleWindow();
static void Main(string[] args)
{
IntPtr handle = GetConsoleWindow();
IntPtr sysMenu = GetSystemMenu(handle, false);
if (handle != IntPtr.Zero)
{
DeleteMenu(sysMenu, SC_MINIMIZE, MF_BYCOMMAND);
DeleteMenu(sysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
DeleteMenu(sysMenu, SC_SIZE, MF_BYCOMMAND);
}
Console.Read();
}
}
static void Main(string[] args)
{
string[] arrDate = { "09.08.2018 13:04:07"
, "11.05.2018 11:03:00"
, "16.07.2018 13:28:12" };
string[] arrFileName = { "nameFile_1301_1602__2018_08_09__13_04_07_990"
, "nameFile_1302_1602__2018_05_11__11_03_40_910"
, "nameFile_1302_1602__2018_07_16__13_28_12_950" };
foreach (var strDate in arrDate)
{
var pattern = GetSearchPattern(strDate);
if (pattern!=null)
{
var fileName = arrFileName.FirstOrDefault(f=>f.Contains(pattern));
if (fileName == null) continue;
string otvet = "Дата: " + strDate + "Файл с этой датой: " + fileName;
Console.WriteLine(otvet);
}
}
}
static string GetSearchPattern(string strDate)
{
DateTime date = new DateTime();
if (!DateTime.TryParse(strDate, out date)) return null;
return date.ToString("__yyyy_MM_dd__HH_mm_ss_");
}
using System;
using MailKit.Net.Imap;
using MailKit;
namespace MailKit_app
{
class Program
{
static void Main(string[] args)
{
using (var client = new ImapClient())
{
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.Connect("imap.yandex.ru", 993, true);
client.Authenticate("login@yandex.ru", "password");
var junk = client.GetFolder(SpecialFolder.Junk);
junk.Open(FolderAccess.ReadOnly);
Console.WriteLine("Total messages: {0}", junk.Count);
Console.WriteLine("Recent messages: {0}", junk.Recent);
for (int i = 0; i < junk.Count; i++)
{
var message = junk.GetMessage(i);
Console.WriteLine("Subject: {0}", message.Subject);
}
client.Disconnect(true);
}
}
}
}
string text = xmlColItems.Descendants("weather")
.Descendants("city")
.Descendants("cityname2").FirstOrDefault()?.Value;
The type 'T' cannot be used as type parameter 'T' in the generic type or method 'Repository'. There is no boxing conversion or type parameter conversion from 'T' to '.IDbUpdatable'.
IDbUpdatable<T>
, тогда данной ошибки не будет.public interface IDbUpdatable<T> where T : IDbUpdatable<T>
{
Repository<T> GetRepository();
int Update();
int Delete();
}
string fileName = System.IO.Path.Combine(Environment.CurrentDirectory, "output.txt");
static async Task Run()
{
Console.WriteLine("Hello from begining \"Run\" method");
int num = 1000000000;
long res = await new TaskFactory().StartNew(() => { return SumZeroToNum(num); });
Console.WriteLine($"Result: {res}");
}
Task t = Run();