본문 바로가기

분류 전체보기311

[C#] 문자열이 모두 숫자인지 아닌지 판별. isdigit를 이용함 public static class StringExtension { /// /// True if all characters in a string is IsDigit(true), False if not /// /// /// public static bool IsNumber(this string me) { foreach (char ch in me) { if (!Char.IsDigit(ch)) return false; } return true; } } Sting Class의 확장 함수이다. 번호가 한개라도 섞여있으면 False가 리턴된다. private void Form1_Load(object sender, EventArgs e) { string a = "1000"; string b = "hi"; string.. 2021. 3. 17.
[C#] Hash를 간단하게 사용해보자 c#은 너무나도 코딩하기 편하게 list, hash, dictionary를 만들어놓았다. 사용하기가 너무 편하다. 근데 링크드 리스트도 쓸 수 있나? 하여튼 이번에는 Hash를 알아볼 것이다. 사용법은 list와 거의 동일하다. using System.Collections 우선 이걸 추가해주어야한다. using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace test { public partial class Form1 : Form { .. 2021. 3. 16.
[C#] List를 간단하게 사용해보자 loadofprogrammer.tistory.com/145 ★ 16. C# - List 사용 예제 List 에 대한 간략한 설명 및 사용 방법을 알아보겠습니다. [1] 일반적으로 배열은 동적으로 크기 조절이 되지 않지만 List는 가능합니다. [2] 리스트를 사용하면 배열의 크기에 대해서 크게 신경쓸 loadofprogrammer.tistory.com using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.W.. 2021. 3. 16.
[C#] ListBox를 사용해보자 (추가,삭제,Clear) 요렇게 만들어보자 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace test { public partial class Form1 : Form { private void Form1_Load(object sender, EventArgs e) { } public Form1() { InitializeComponent(); } privat.. 2021. 3. 16.
[C#] Txt 파일에 한글을 읽거나 쓸 때 깨진다면? string textValue = System.IO.File.ReadAllText(path); // 읽을 때 한글이 깨짐 string textValue = System.IO.File.ReadAllText(path, Encoding.Default); // 안 깨짐 System.IO.File.WriteAllText(savePath, textValue); // 파일 쓸 때 한글이 깨짐. System.IO.File.WriteAllText(savePath, textValue, Encoding.Default); // 파일 쓸 때 깨지지 않음. Encoding.Defaul를 해주면 안깨진다. 진짜다. 2021. 3. 16.
[C#] 갑자기 삭제된 개체에 액세스 할 수 없습니다 라는 에러가 발생한 경우 나 같은 경우에는 public partial class Form1 : Form -> 맨 윗줄에 있는 코드. 이 코드 전에 다른 코드를 적어서 발생한 문제였다. 코드를 옮기니까 해결되었다. 2021. 3. 16.