Writer/WarmingUp Code
-
워밍업 코드 클래스 2Writer/WarmingUp Code 2008. 12. 23. 21:18
using System; namespace classInterface { // 추상클래스 (선언 최상위 부모클래스) abstract class A { //맴버 변수 public string name = "전광식"; //맴버메소드 (추상클래스는 메소드를 구현할 수 있다) public void Foo() { Console.WriteLine("A class Foo Method"); } // 추상메소드 (구현이 없음) public abstract void Goo(); } // 자식 클래스 선언 (A클래스를 상속 받음) class B : A { //맴버변수 public int age = 31; //부모의 추상 메소드를 Override하여 재구현 public override void Goo() { Console.W..
-
워밍업 코드 클래스Writer/WarmingUp Code 2008. 12. 23. 20:45
using System; namespace TestClass1 { class Soccer { public delegate void SoccerDel(); public event SoccerDel eventDel; private string[] player; public int length { get{return this.player.Length; } } public Soccer() { player = new string[] {"전광식","박주영","박지성","이영표" }; } public string this[int index] { get { return this.player[index]; } } public void ShotExecute() { if ( eventDel != null) { eventDe..
-
C# ADO.NET 접속 Console접속 SELECT ,UPDATEWriter/WarmingUp Code 2008. 11. 12. 09:51
using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; namespace ConLess { class Program { static void Main(string[] args) { // 커넥션 SqlConnection conn = new SqlConnection(); conn.ConnectionString = @"data source = (local); initial catalog=northwind; user id=sa ; password="; // 데이터세을 쿼리 string selqry = "SELECT categoryID, categoryName FR..
-
ADO.NET 접속Writer/WarmingUp Code 2008. 10. 29. 09:05
using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; namespace ConsoleApplication51 { class Program { static void Main(string[] args) { string source = "server=KWANG-SIK\\sql2005 ; database= pubs ; uid=sa; pwd=p@ssw0rd!"; SqlConnection conn = new SqlConnection(source); try { conn.Open(); Console.WriteLine("접속성공"); } catch (Exception) ..
-
-
C# Thread 스레드Writer/WarmingUp Code 2008. 10. 29. 07:15
///////////////////////// 멀티 스레드 /////////////////////////// using System; using System.Threading; class threadtest { static void ThreadProc() { for (int i = 0; i < 100; i++) { Console.WriteLine(i); Thread.Sleep(500); } Console.WriteLine("작업스레드종료"); } static void Main() { Thread T = new Thread(new ThreadStart(ThreadProc)); T.Start(); for (;;) { ConsoleKeyInfo cki; cki = Console.ReadKey(); if(cki..
-
-
abstract interfaceWriter/WarmingUp Code 2008. 10. 15. 14:17
using System; interface IAdd { int Add(int a, int b); } interface IMinus { int Minus(int a , int b); } abstract class abMethod { public int Add(int a, int b) { int tot = a+b; return tot; } public abstract int Minus(int a, int b); } class NewInter : IAdd , IMinus { public int Add(int a, int b) { int add= a+b; return add; } public int Minus(int a, int b) { int m = a-b; return m; } } class ABtest :..
-
델리게이트 이벤트 소스 노가다 2Writer/WarmingUp Code 2008. 10. 14. 00:18
using System; class MainApp { delegate void stuff(); static void Main() { stuff s = new stuff(sugar); stuff c = new stuff(cream); stuff m = new stuff(milk); stuff cafe = new stuff(coffee); Console.WriteLine("비엔나 커피 만들기"); stuff vienna = s + c + cafe; vienna(); Console.WriteLine(); stuff cafeaulait = s + m + cafe; cafeaulait(); Console.WriteLine(); stuff black = cafeaulait - m - s; black(); Conso..
-
델리게이트 이벤트 소스 노가다Writer/WarmingUp Code 2008. 10. 13. 21:40
using System; class MainApp { public delegate void Mix(string s);// 델레게이트 선언 public static void Coffee(string s) { Console.WriteLine("{0}",s); } public static void CoCoa(string s) { Console.WriteLine("{0}",s); } public static void Main() { Mix Tea = new Mix(Coffee); Tea("salt"); Tea = new Mix(CoCoa); Tea("milk"); } } using System; class delTest { public delegate void Mix(string s); public static..
-
눈물의 소스 박스형 for와 if 사용 첨부 상철 상봉 오윤Writer/WarmingUp Code 2008. 10. 9. 14:24
/////////////////////////////////////////////////////////////////////////////////////////////////// 전광식 /////////////////////////////////////////////////////////////////////////////////////////////////// using System; namespace jks { class program { public void jks() { string ch=null; Console.WriteLine("a : 박스형 for"); Console.WriteLine("b : 박스형 if "); ch=Console.ReadLine(); if (ch == "a") { int ..
-
소스 복습Writer/WarmingUp Code 2008. 10. 8. 01:58
/*using System; class Absolute { public static void Main() { GetAbsolute(-23); GetAbsolute(392.3f); GetAbsolute(-293.2343337); } private static void GetAbsolute(int a) { int b = 0; if (a < 0) b = b * -1; else b = a; Console.WriteLine("{0}{1}",a,b); } private static void GetAbsolute(float a) { float b = 0; if (a < 0) b = b * -1; else b = a; Console.WriteLine("{0}{1}", a, b); } private static void..
-
객체지향 소스Writer/WarmingUp Code 2008. 10. 7. 14:02
using System; namespace nam{ class Student{ public string Name; public int Age; public int cNum; public void setStudent(){ Console.Write("이름을 입력해라."); this.Name = Console.ReadLine(); Console.WriteLine("나이를 입력해라."); this.Age = int.Parse(Console.ReadLine()); Console.WriteLine("학번을 입력해라."); this.cNum = int.Parse(Console.ReadLine()); } public void getStudent(){ Console.WriteLine("{0}, {1}, {2} ",thi..
-
성적출력Writer/WarmingUp Code 2008. 10. 7. 00:45
using System; class intstring { } class testman { public static void Main() { string i,strName=null, strKorean=null, strEnglish=null, strMath=null,number=null; // i = 출력할 학생수 //number = 번호선택 int strSum=0, numberInt=0 , cnt=0, cntPlus=-1 ,iInt; // float strAvg; Console.Write("출력할 학생수를 입력하세요 : "); i=Console.ReadLine(); Console.WriteLine(""); Console.WriteLine(" {0} 명의 학생을 출력할수있습니다 ",i); Console.Wr..
-
소스연습Writer/WarmingUp Code 2008. 10. 6. 21:19
using System; class student { public static void Main() { string strName = null, strKorean = null, strEnglish = null, strMath = null; int strSum = 0 , cnt=1; float strAvg = 0; while(cnt == 1) { Console.WriteLine("===================================="); Console.WriteLine("===================================="); Console.WriteLine("===이름 국어 영어 수학 총점 평균==="); Console.WriteLine("=====================..
-
프로퍼티 웜업소스Writer/WarmingUp Code 2008. 10. 5. 17:19
using System; using System.Collections.Generic; using System.Text; namespace pt1 { class Point1 { public int a; public int b; public Point1(int a,int b) { this.a = a; this.b = b; } } class Point2 { private int aa; private int bb; public void set(int aa,int bb) { this.aa = aa; this.bb = bb; } public int getaa() { return aa; } public int getbb() { return bb; } } class Point3 { private int xx; priv..
-
string ToString() bool float object enum boxing charWriter/WarmingUp Code 2008. 10. 4. 15:27
using System; class stringTest { public static void Main() { sting a = "제이름은"; string b = "전광식입니다"; string c = "강민주입니다"; string e = a+b; string f = a+c; int g = 2001; string h = "올해는" + g.ToString +"년입니다"; Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); } } using System; class objectTest { public static void Main() { object a = 22; object b = 3.14; objenct c = "abc"; Console.Write..
-
복습Writer/WarmingUp Code 2008. 10. 2. 19:48
/* class car//프로그램 세계에서는 개체를 하나의 데이터형으로간주 // car 데이터형 E또는 car형이라고 명명한 { public void Move() { } } class calss1 { static void Main() { car c = new car();// 객체 생성 new 연산자 이용 c.Move(); // Move 메서드 부르기 } } // 네임스페이스는 클래스를 분류할 때 사용 // ex) Vehicle.car // vehicle.airplane // 클래스와 네임스페이스 예제 namespace drawObject { class point { } class rectangle { } class ellipse { } } */ using System; //using drawObject;..
-
클래스 구조체Writer/WarmingUp Code 2008. 10. 1. 12:42
using System; class cstest { public static void Method1(ctime t) { t.hour =12; } public static void Method2(stime t) { t.hour=12; } public static void Main() { ctime c = new ctime(); c.hour= 9; Method1(c); Console.WriteLine("{0}",c.hour); stime s = new stime(); s.hour=9; Method2(); Console.WriteLine("{0}",s.hour); } } class ctime { public int hour; } struct stime { public int hour; } ///////////..