목록C# .NET (5)
닌자고양이
1.콘솔에서 dotnet publish 명령어를 사용하는 portable한 방법 프로젝트 파일이 있는 디렉터리에서 다음 명령어를 입력한다. dotnet publish -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true 옵션 설명: -r win-x64 대상 시스템의 Runtime-ID로 win-x64, win-x86, linux-x64, linux-arm, linux-arm64, osx-x64 등 --self-contained true 배포에 자체적으로 .NET 런타임을 포함한다. false 또는 생략시 시스템에 설치된 런타임을 사용하며 일치하는 런타임 버전이 없을 시 실행이 안된다..
Linq 사용 string[] Split(string str, int len) { var chunks = Enumerable.Range(0, (str.Length + len - 1) / len); return chunks.Select(p => str.Substring(p * len, Math.Min(str.Length - p * len, len))).ToArray(); } 반복문 사용 string[] Split(string str, int len) { int i, count = (str.Length + len - 1) / len; var arr = new string[count]; for (i = 0; i < count - 1; i++) arr[i] = str.Substring(i * len, len);..
using System.Runtime.InteropServices; class Program { [DllImport("msvcrt.dll")] public static extern int printf(string format, __arglist); public static int printf(string format) => printf(format, __arglist()); [DllImport("msvcrt.dll")] public static extern int scanf(string format, __arglist); public static int scanf(string format) => scanf(format, __arglist()); [DllImport("msvcrt.dll")] static ..
bool IsOverlap(TimeSpan a1, TimeSpan a2, TimeSpan b1, TimeSpan b2) { if (a1 > a2) return IsOverlap(a1, TimeSpan.FromHours(24), b1, b2) || IsOverlap(TimeSpan.Zero, a2, b1, b2); else if (b1 > b2) return IsOverlap(a1, a2, b1, TimeSpan.FromHours(24)) || IsOverlap(a1, a2, TimeSpan.Zero, b2); else return (a1