[C#] Stack 사용
2023. 3. 26. 02:01ㆍ프로그래밍/C#
using System;
using System.Collections.Generic;
public class Solution
{
public void solution()
{
Stack<char> tmp = new Stack<char>();
//추가
tmp.Push('A');
tmp.Push('B');
tmp.Push('C');
//제거
tmp.Pop(); //반환 'C', 상단 원소 제거
tmp.Peek(); //반환X, 상단 원소 제거
tmp.Clear(); //반환X, 전체 삭제
//IsEmpty
if(tmp.Count == 0)
return; //비어있음
// 특정 원소 포함
if(tmp.Contains('A'))
//'A'포함되어 있는지 파악
//배열 변환
char[] array = tmp.ToArray();
}
}
'프로그래밍 > C#' 카테고리의 다른 글
[WPF] TreeView SelectedItem Clear (0) | 2024.05.28 |
---|---|
[WPF] TextBox 숫자값만 입력받기. (0) | 2024.05.17 |
[C#] int 배열 사용 (0) | 2023.03.23 |
[C#] String 배열 다루기 (0) | 2023.03.23 |
string.Equals 사용시 Null 처리 (0) | 2023.03.17 |