This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| playground:playground [2015/07/19 18:09] – ledyx | playground:playground [2021/02/07 03:15] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| = PlayGround = | = PlayGround = | ||
| - | <sxh csharp> | ||
| - | using System; | ||
| - | using System.Collections; | ||
| - | using System.Collections.Generic; | ||
| - | using System.Linq; | ||
| - | namespace ConsoleApplication1 | + | <code clojure> |
| - | { | + | (defn do-something [] |
| - | | + | (println " |
| - | { | + | </ |
| - | public static MyClassManager MyClass { get { return MyClassManager.Instance; | + | |
| - | } | + | |
| - | |||
| - | |||
| - | /* 1단계 */ | ||
| - | |||
| - | public class MyClassManager | ||
| - | { | ||
| - | private List< | ||
| - | |||
| - | private static MyClassManager instance = null; | ||
| - | |||
| - | private MyClassManager() { } | ||
| - | |||
| - | public static MyClassManager Instance | ||
| - | { | ||
| - | get | ||
| - | { | ||
| - | if (instance == null) | ||
| - | instance = new MyClassManager(); | ||
| - | |||
| - | return instance; | ||
| - | } | ||
| - | } | ||
| - | |||
| - | public void Add(int a, int b) | ||
| - | { | ||
| - | myList.Add(new MyClass(a, b)); | ||
| - | } | ||
| - | |||
| - | public void RemoveAt(int index) | ||
| - | { | ||
| - | myList.RemoveAt(index); | ||
| - | } | ||
| - | |||
| - | public MyClass ElementAt(int index) | ||
| - | { | ||
| - | return myList.ElementAt(index); | ||
| - | } | ||
| - | |||
| - | public int Length | ||
| - | { | ||
| - | get | ||
| - | { | ||
| - | return myList.Count; | ||
| - | } | ||
| - | } | ||
| - | } | ||
| - | |||
| - | public class MyClass | ||
| - | { | ||
| - | public SubClassManager myCustomList = new SubClassManager(); | ||
| - | |||
| - | |||
| - | public int a, b; | ||
| - | |||
| - | public MyClass(int a, int b) | ||
| - | { | ||
| - | this.a = a; | ||
| - | this.b = b; | ||
| - | |||
| - | } | ||
| - | } | ||
| - | |||
| - | |||
| - | |||
| - | /* 2단계 - 마치 List처럼 전체 재정의 */ | ||
| - | |||
| - | public class SubClassManager | ||
| - | { | ||
| - | /* Singleton 사용X */ | ||
| - | private List< | ||
| - | |||
| - | public void Add(int x, int y) | ||
| - | { | ||
| - | myList.Add(new SubClass(x, y)); | ||
| - | } | ||
| - | |||
| - | public SubClass this[int index] | ||
| - | { | ||
| - | get | ||
| - | { | ||
| - | return myList[index]; | ||
| - | } | ||
| - | set | ||
| - | { | ||
| - | myList[index] = value; | ||
| - | } | ||
| - | } | ||
| - | } | ||
| - | |||
| - | public class SubClass | ||
| - | { | ||
| - | public SubClass(int x, int y) | ||
| - | { | ||
| - | this.x = x; | ||
| - | this.y = y; | ||
| - | } | ||
| - | |||
| - | |||
| - | public int x { get; set; } | ||
| - | public int y { get; set; } | ||
| - | } | ||
| - | } | ||
| - | </ | ||