This file contains 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
/* | |
출처 : http://www.csharpstudy.com//CS6/CSharp-null-conditional-operator.aspx | |
*/ | |
// rows가 NULL이면 cnt 도 NULL | |
// rows가 NULL이 아니면 cnt는 실제 rows 갯수 | |
int? cnt = rows?.Count; | |
// customers 컬렉션이 NULL이면 c는 NULL | |
// 아니면, c는 첫번째 배열요소 |
This file contains 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
Rectangle r = new Rectangle(); | |
r.Height = 10; | |
r.Width = 32; | |
// Format string 앞에 $ 를 붙인다 | |
// {} 안에 속성 혹은 계산식 등을 넣을 수 있다. | |
string s = $"{r.Height} x {r.Width} = {(r.Height * r.Width)}"; | |
Console.WriteLine(s); | |
This file contains 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
# ===================================== | |
# 초기 스크립트 실행 허용으로 설정하는 방법 | |
# ===================================== | |
Set-ExecutionPolicy RemoteSigned -Force | |
# ===================================== | |
# 파라미터 지정 방법 | |
# ===================================== | |
# 소스의 최상단에 있어야 함 | |
param ( |
This file contains 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
# 마지막 결과값 문자열 | |
$$ |
This file contains 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
# =================================== | |
# Host명 변경 | |
# =================================== | |
$old_hostname = hostname | |
$new_hostname = "새로운 Host명" | |
netdom renamecomputer $old_hostname /newname:$new_hostname /force | |
# =================================== | |
# 터미널 접속 포트 방화벽에 추가 | |
# =================================== |
This file contains 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
# POST 방식 전송 | |
$postParams = @{ | |
name1=val1; | |
name2=val2; | |
} | |
Invoke-WebRequest -Uri http://api.service.com/call.aspx -Method POST -Body $postParams |
This file contains 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
# ===================================== | |
# SQL Server를 제어하기 위한 어셈블리 로드 | |
# ===================================== | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | Out-Null | |
# ===================================== | |
# SQL Server 버전 | |
# ===================================== | |
$srv = New-Object "Microsoft.SqlServer.Management.Smo.Server" "." |
This file contains 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
# ========================== | |
# IIS 사이트 일괄 삭제 | |
# ========================== | |
Import-Module webadministration | |
foreach ($i in get-childitem IIS:\Sites\ -Name) {remove-item ("IIS:Sites\"+$i) -R} | |
This file contains 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
public Program() | |
{ | |
// Thread의 처리 완료 이벤트를 받기 위한 클래스 | |
ManualResetEvent doneEvent = new ManualResetEvent(false); | |
// Thread를 정의하고 시작 한다. | |
Thread t1 = new Thread(new ThreadStart(new ThreadExam(doneEvent).ThreadMethod)); | |
// Thread 시작 | |
t1.Start(); |
This file contains 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
while (true) | |
{ | |
Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); | |
IAsyncResult result = _socket.BeginConnect(host, port, (ar) => | |
{ | |
}, null); | |
// 연결이 될때 까지 timeout 시간 동안 대기 한다. | |
result.AsyncWaitHandle.WaitOne(TimeSpan.FromMilliseconds(timeout), false); |
OlderNewer