4강

성연주·2021년 9월 3일
0

MessageBox

MessageBox.Show("메세지 박스에 보일 내용");

// = alert창 같은 팝업창으로 뜸

IsNullOrWhiteSpace

string.IsNullOrWhiteSpace(sum1.Text)

// 공백 또는 space에 대해 bool 타입으로 return 하는 함수

사용 예시

if (string.IsNullOrWhiteSpace(sum1.Text))
	Console.WriteLine("I'm ready!");

TryParse

Int32.TryParse()
int.TryParse(Sum1.Text, out n1)

// 둘 다 bool 타입으로 return
-> boolean TryParse(string s, out int result)

사용 예시

if (int.TryParse(Sum1.Text, out n1))
	MessageBox.Show("lolo");

// true : if문 內 코드 실행 + n1 변수 생성 및 n1에 Sum1.Text의 int로 변환된 결과 값 등록됨
// false : 그냥 넘어감

Focus

if (int.TryParse(Sum1.Text, out n1)){
	MessageBox.Show("lolo");
    Sum1.Focus();
}

-> 선택된 TextBox로 입력 커서가 이동됨

SelectAll

if (int.TryParse(Sum1.Text, out n1)){
	MessageBox.Show("lolo");
    Sum1.SelectAll();
    Sum1.Focus();
}

-> 선택된 TextBox에 있는 모든 내용이 선택됨

0개의 댓글