본문 바로가기

전체 글

C# 명령줄 인수 class CommandLine { static void Main(string[] args) { // The Length property provides the number of array elements System.Console.WriteLine("parameter count = {0}", args.Length); for (int i = 0; i < args.Length; i++) { System.Console.WriteLine("Arg[{0}] = [{1}]", i, args[i]); } } } class CommandLine2 { static void Main(string[] args) { System.Console.WriteLine("Number of command line parameters .. 더보기
C# 비트 연산 using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace bitByte { class Program { static void PrintBits(BitArray ba) { for (int i = 0; i < ba.Count; i++) { Console.Write(ba[i] ? "1" : "0"); } Console.WriteLine(); } static void Main(string[] args) { // (// (1) 한 byte 를 Hex 문자로 변환하는 방법법 byte bbb1 = 0xFE.. 더보기
C# 소켓 클라이언트 socket client using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; using System.Threading.Tasks; namespace SocketClient { class Program { public class StateObject { // Client socket. public Socket workSocket = null; // Size of receive buffer. public const int BufferSize = 256; // Receive buffer. public byte[] .. 더보기
C# 소켓 서버 socket server using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; using System.Threading.Tasks; namespace SocketServer { class Program { static void Main(string[] args) { AsynchronousSocketListener.StartListening(); } } // State object for reading client data asynchronously public class StateObject { // Clien.. 더보기
C# 스레드 thread using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace thread { public class ServerClass { // The method that will be called when the thread is started. public void InstanceMethod() { Console.WriteLine( "ServerClass.InstanceMethod is running on another thread."); // Pause for a moment to provide a dela.. 더보기
C# 타이머 Timer using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using MySql.Data.MySqlClient; using Net.Common; using System.Net; using System.IO; using System.Net.Json; namespace MobilePushCheckAgent { public partial class .. 더보기
C# 재귀호출 namespace RecursiveToLoopSamplesCS { class BinaryRecursion { public static int FibNum(int n) { if (n < 1) { return -1; } if (1 == n || 2 == n) { return 1; } int addVal = FibNum(n - 1); addVal += FibNum(n - 2); return addVal; } } } 더보기
C# 정렬 sort using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sort { class User { public string Name; public int Age; public User(string _name, int _age) { Name = _name; Age = _age; } } class Sortt { public void sort1() { int[] intArray = new int[5] { 8, 10, 2, 6, 3 }; for (int i = 4; i > 0; i--) { for (int j = 0; j < i; j++) { if (.. 더보기
C# BinarySearchTree 이진탐색트리 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BinarySearchTree { public class BinaryTreeNode { public T Data { get; set; } public BinaryTreeNode Left { get; set; } public BinaryTreeNode Right { get; set; } public BinaryTreeNode(T data) { this.Data = data; } } // // 이진검색트리 클래스스 public class BST { private BinaryTreeNod.. 더보기
C# 파일 읽기 static void Main(string[] args) { int counter=0; string line; //파일 읽기 System.IO.StreamReader file = new System.IO.StreamReader("access.log"); while((line = file.ReadLine()) != null) { System.Console.WriteLine(line); counter++; } file.Close(); } 더보기