From 2627122cd04c2faf994e4e34b367377de90004ca Mon Sep 17 00:00:00 2001 From: phkim Date: Tue, 12 Jul 2022 16:43:56 +0900 Subject: [PATCH] adv grammer --- .gitattributes | 63 ++++++ .gitignore | 189 ++++++++++++++++++ AnonymousMethod/AnonymousMethod.csproj | 68 +++++++ AnonymousMethod/App.config | 6 + AnonymousMethod/DelegateInvoke.cs | 38 ++++ .../DelegateTypeVsAnonymousMethod.cs | 45 +++++ AnonymousMethod/MyForm.cs | 20 ++ AnonymousMethod/Program.cs | 25 +++ AnonymousMethod/Properties/AssemblyInfo.cs | 36 ++++ Delegate/App.config | 6 + Delegate/Basic.cs | 30 +++ Delegate/Delegate.csproj | 68 +++++++ Delegate/EventDelegate.cs | 26 +++ Delegate/InterA.cs | 32 +++ Delegate/InterB.cs | 48 +++++ Delegate/InterC.cs | 26 +++ Delegate/Program.cs | 72 +++++++ Delegate/Properties/AssemblyInfo.cs | 36 ++++ DelegateForm/App.config | 6 + DelegateForm/DelegateForm.csproj | 88 ++++++++ DelegateForm/Form1.Designer.cs | 39 ++++ DelegateForm/Form1.cs | 37 ++++ DelegateForm/MyArea.cs | 26 +++ DelegateForm/Program.cs | 22 ++ DelegateForm/Properties/AssemblyInfo.cs | 36 ++++ DelegateForm/Properties/Resources.Designer.cs | 71 +++++++ DelegateForm/Properties/Resources.resx | 117 +++++++++++ DelegateForm/Properties/Settings.Designer.cs | 30 +++ DelegateForm/Properties/Settings.settings | 7 + DerivedClass/AbstractClass.cs | 14 ++ DerivedClass/App.config | 6 + DerivedClass/DerivedA.cs | 23 +++ DerivedClass/DerivedClass.csproj | 60 ++++++ DerivedClass/Program.cs | 22 ++ DerivedClass/Properties/AssemblyInfo.cs | 36 ++++ ExtensionMethod/App.config | 6 + ExtensionMethod/ExClass.cs | 35 ++++ ExtensionMethod/ExtensionMethod.csproj | 59 ++++++ ExtensionMethod/Program.cs | 22 ++ ExtensionMethod/Properties/AssemblyInfo.cs | 36 ++++ Generics/App.config | 6 + Generics/Generics.csproj | 60 ++++++ Generics/MyStack.cs | 29 +++ Generics/Program.cs | 17 ++ Generics/Properties/AssemblyInfo.cs | 36 ++++ Generics/TypeContraintStack.cs | 60 ++++++ Interface/App.config | 6 + Interface/IComparable.cs | 13 ++ Interface/Interface.csproj | 60 ++++++ Interface/MyClass.cs | 23 +++ Interface/Program.cs | 15 ++ Interface/Properties/AssemblyInfo.cs | 36 ++++ dotNetAdvancedGrammer.sln | 58 ++++++ dotNetAdvancedGrammer/App.config | 6 + dotNetAdvancedGrammer/Indexer.csproj | 59 ++++++ dotNetAdvancedGrammer/IndexerClass.cs | 32 +++ dotNetAdvancedGrammer/Program.cs | 19 ++ .../Properties/AssemblyInfo.cs | 36 ++++ 58 files changed, 2203 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 AnonymousMethod/AnonymousMethod.csproj create mode 100644 AnonymousMethod/App.config create mode 100644 AnonymousMethod/DelegateInvoke.cs create mode 100644 AnonymousMethod/DelegateTypeVsAnonymousMethod.cs create mode 100644 AnonymousMethod/MyForm.cs create mode 100644 AnonymousMethod/Program.cs create mode 100644 AnonymousMethod/Properties/AssemblyInfo.cs create mode 100644 Delegate/App.config create mode 100644 Delegate/Basic.cs create mode 100644 Delegate/Delegate.csproj create mode 100644 Delegate/EventDelegate.cs create mode 100644 Delegate/InterA.cs create mode 100644 Delegate/InterB.cs create mode 100644 Delegate/InterC.cs create mode 100644 Delegate/Program.cs create mode 100644 Delegate/Properties/AssemblyInfo.cs create mode 100644 DelegateForm/App.config create mode 100644 DelegateForm/DelegateForm.csproj create mode 100644 DelegateForm/Form1.Designer.cs create mode 100644 DelegateForm/Form1.cs create mode 100644 DelegateForm/MyArea.cs create mode 100644 DelegateForm/Program.cs create mode 100644 DelegateForm/Properties/AssemblyInfo.cs create mode 100644 DelegateForm/Properties/Resources.Designer.cs create mode 100644 DelegateForm/Properties/Resources.resx create mode 100644 DelegateForm/Properties/Settings.Designer.cs create mode 100644 DelegateForm/Properties/Settings.settings create mode 100644 DerivedClass/AbstractClass.cs create mode 100644 DerivedClass/App.config create mode 100644 DerivedClass/DerivedA.cs create mode 100644 DerivedClass/DerivedClass.csproj create mode 100644 DerivedClass/Program.cs create mode 100644 DerivedClass/Properties/AssemblyInfo.cs create mode 100644 ExtensionMethod/App.config create mode 100644 ExtensionMethod/ExClass.cs create mode 100644 ExtensionMethod/ExtensionMethod.csproj create mode 100644 ExtensionMethod/Program.cs create mode 100644 ExtensionMethod/Properties/AssemblyInfo.cs create mode 100644 Generics/App.config create mode 100644 Generics/Generics.csproj create mode 100644 Generics/MyStack.cs create mode 100644 Generics/Program.cs create mode 100644 Generics/Properties/AssemblyInfo.cs create mode 100644 Generics/TypeContraintStack.cs create mode 100644 Interface/App.config create mode 100644 Interface/IComparable.cs create mode 100644 Interface/Interface.csproj create mode 100644 Interface/MyClass.cs create mode 100644 Interface/Program.cs create mode 100644 Interface/Properties/AssemblyInfo.cs create mode 100644 dotNetAdvancedGrammer.sln create mode 100644 dotNetAdvancedGrammer/App.config create mode 100644 dotNetAdvancedGrammer/Indexer.csproj create mode 100644 dotNetAdvancedGrammer/IndexerClass.cs create mode 100644 dotNetAdvancedGrammer/Program.cs create mode 100644 dotNetAdvancedGrammer/Properties/AssemblyInfo.cs diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7964536 --- /dev/null +++ b/.gitignore @@ -0,0 +1,189 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +x64/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Roslyn cache directories +*.ide/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +#NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +## TODO: Comment the next line if you want to checkin your +## web deploy settings but do note that will include unencrypted +## passwords +#*.pubxml + +# NuGet Packages Directory +packages/* +## TODO: If the tool you use requires repositories.config +## uncomment the next line +#!packages/repositories.config + +# Enable "build/" folder in the NuGet Packages folder since +# NuGet packages use it for MSBuild targets. +# This line needs to be after the ignore of the build folder +# (and the packages folder if the line above has been uncommented) +!packages/build/ + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml \ No newline at end of file diff --git a/AnonymousMethod/AnonymousMethod.csproj b/AnonymousMethod/AnonymousMethod.csproj new file mode 100644 index 0000000..d7eb450 --- /dev/null +++ b/AnonymousMethod/AnonymousMethod.csproj @@ -0,0 +1,68 @@ + + + + + Debug + AnyCPU + {2940C9B1-249A-43B0-8A64-6432DBBD2714} + Exe + Properties + AnonymousMethod + AnonymousMethod + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + Form + + + Form + + + Form + + + + + + + + + + \ No newline at end of file diff --git a/AnonymousMethod/App.config b/AnonymousMethod/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/AnonymousMethod/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/AnonymousMethod/DelegateInvoke.cs b/AnonymousMethod/DelegateInvoke.cs new file mode 100644 index 0000000..115af50 --- /dev/null +++ b/AnonymousMethod/DelegateInvoke.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AnonymousMethod +{ + class DelegateInvoke : Form + { + MethodInvoker mi; + + public DelegateInvoke() + { + // 델리게이트 타입이 아닌 무명메서드는 invoke 할 수 없음 + //this.Invoke(delegate { this.Text = "Wrong Way"; }); + + mi = new MethodInvoker(delegate() + { + this.Text = "Left Click!"; + }); + + this.MouseUp += DelegateInvoke_MouseUp; + } + + void DelegateInvoke_MouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + this.Invoke(mi); + else if (e.Button == MouseButtons.Right) + this.Invoke((MethodInvoker)delegate + { + this.Text = "Right Click!"; + }); + } + } +} diff --git a/AnonymousMethod/DelegateTypeVsAnonymousMethod.cs b/AnonymousMethod/DelegateTypeVsAnonymousMethod.cs new file mode 100644 index 0000000..f1dc1c6 --- /dev/null +++ b/AnonymousMethod/DelegateTypeVsAnonymousMethod.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AnonymousMethod +{ + class DelegateTypeVsAnonymousMethod : Form + { + // Delegate 타입 + public delegate int SumDelegate(int a, int b); + + public DelegateTypeVsAnonymousMethod() + { + // Delegate 사용 + SumDelegate sumDel = new SumDelegate(MySum); + int result = sumDel(1, 2); + + // 무명메서드1 + this.Click += new EventHandler(delegate(object sender, EventArgs e) + { + MessageBox.Show("Way1"); + }); + + // 무명메서드2 + this.Click += (EventHandler)delegate(object sender, EventArgs e) + { + MessageBox.Show("Way2"); + }; + + // 무명메서드3 + this.Click += delegate + { + MessageBox.Show("Way3"); + }; + } + + private int MySum(int a, int b) + { + return 0; + } + } +} diff --git a/AnonymousMethod/MyForm.cs b/AnonymousMethod/MyForm.cs new file mode 100644 index 0000000..2268f3e --- /dev/null +++ b/AnonymousMethod/MyForm.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AnonymousMethod +{ + class MyForm : Form + { + public MyForm() + { + this.Click += delegate(object sender, EventArgs e) + { + MessageBox.Show("Anonymous Method!"); + }; + } + } +} diff --git a/AnonymousMethod/Program.cs b/AnonymousMethod/Program.cs new file mode 100644 index 0000000..d80792f --- /dev/null +++ b/AnonymousMethod/Program.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AnonymousMethod +{ + class Program + { + static void Main(string[] args) + { + //MyForm form = new MyForm(); + //form.ShowDialog(); + + + //DelegateTypeVsAnonymousMethod form = new DelegateTypeVsAnonymousMethod(); + //form.ShowDialog(); + + + DelegateInvoke form = new DelegateInvoke(); + form.ShowDialog(); + } + } +} diff --git a/AnonymousMethod/Properties/AssemblyInfo.cs b/AnonymousMethod/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..bdd54e9 --- /dev/null +++ b/AnonymousMethod/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("AnonymousMethod")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AnonymousMethod")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("99961339-904a-406f-9677-f63f76950d8e")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Delegate/App.config b/Delegate/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Delegate/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Delegate/Basic.cs b/Delegate/Basic.cs new file mode 100644 index 0000000..dd03c4c --- /dev/null +++ b/Delegate/Basic.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Delegate +{ + class Basic + { + delegate int MyDelegate(string s); + + public void Test() + { + MyDelegate m = new MyDelegate(StringToInt); + Run(m); + } + + private int StringToInt(string s) + { + return int.Parse(s); + } + + private void Run(MyDelegate m) + { + int i = m("123"); + Console.WriteLine(i); + } + } +} diff --git a/Delegate/Delegate.csproj b/Delegate/Delegate.csproj new file mode 100644 index 0000000..996f173 --- /dev/null +++ b/Delegate/Delegate.csproj @@ -0,0 +1,68 @@ + + + + + Debug + AnyCPU + {2624BEFB-1FF7-4403-8542-CE2B49BB2299} + Exe + Properties + Delegate + Delegate + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + Form + + + + + Form + + + + + + + + + + \ No newline at end of file diff --git a/Delegate/EventDelegate.cs b/Delegate/EventDelegate.cs new file mode 100644 index 0000000..b201faa --- /dev/null +++ b/Delegate/EventDelegate.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Delegate +{ + class EventDelegate : Form + { + public delegate void ClickEvent(object sender); + public event ClickEvent MyClick; + + public EventDelegate() + { + this.MouseClick += delegate { MyAreaClicked(); }; + } + + private void MyAreaClicked() + { + if (MyClick != null) + MyClick(this); + } + } +} diff --git a/Delegate/InterA.cs b/Delegate/InterA.cs new file mode 100644 index 0000000..3d76bbe --- /dev/null +++ b/Delegate/InterA.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Delegate +{ + class InterA + { + private delegate void RunDelegate(int i); + + private void PrintDec(int val) + { + Console.WriteLine("{0}", val); + } + + private void PrintHex(int val) + { + Console.WriteLine("0x{0:X}", val); + } + + public void DoWork() + { + RunDelegate run = new RunDelegate(PrintDec); + run(1024); + + run = PrintHex; + run(1024); + } + } +} diff --git a/Delegate/InterB.cs b/Delegate/InterB.cs new file mode 100644 index 0000000..e8249af --- /dev/null +++ b/Delegate/InterB.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Delegate +{ + class InterB + { + public delegate int CompareDelegate(int i1, int i2); + + public static void Sort(int[] arr, CompareDelegate comp) + { + if (arr.Length < 2) + return; + + Console.WriteLine("함수 Prototype: " + comp.Method); + + int ret; + for (int i = 0; i < arr.Length - 1; i++) + { + for (int j = i + 1; j < arr.Length; j++) + { + ret = comp(arr[i], arr[j]); + if (ret == -1) + { + int tmp = arr[j]; + arr[j] = arr[i]; + arr[i] = tmp; + } + } + } + + Show(arr); + } + + private static void Show(int[] arr) + { + foreach (int i in arr) + { + Console.WriteLine(i + " "); + } + + Console.WriteLine(); + } + } +} diff --git a/Delegate/InterC.cs b/Delegate/InterC.cs new file mode 100644 index 0000000..164c265 --- /dev/null +++ b/Delegate/InterC.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Delegate +{ + class InterC : Form + { + public delegate void ClickDelegate(object sender); + public ClickDelegate MyClick; + + public InterC() + { + this.MouseClick += delegate { MyAreaClicked(); }; + } + + private void MyAreaClicked() + { + if (MyClick != null) + MyClick(this); + } + } +} diff --git a/Delegate/Program.cs b/Delegate/Program.cs new file mode 100644 index 0000000..a3121aa --- /dev/null +++ b/Delegate/Program.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Delegate +{ + class Program + { + static InterC area; + static EventDelegate form; + + static void Main(string[] args) + { + //Basic basic = new Basic(); + //basic.Test(); + + + //InterA clsA = new InterA(); + //clsA.DoWork(); + + //int[] arr = new int[] { 5, 53, 3, 6, 8, 43, 64, 33, 12 }; + //InterB.CompareDelegate compDelegate = AscendingCompare; + //InterB.Sort(arr, compDelegate); + //compDelegate = DescendingCompare; + //InterB.Sort(arr, compDelegate); + + + //area = new InterC(); + //area.MyClick += Area_Click; + //area.MyClick += After_Click; + //area.ShowDialog(); + + + form = new EventDelegate(); + form.MyClick += Area_Click; + form.MyClick += After_Click; + //form.MyClick(this); // 클래스 외부에서 사용할 수 없음 + form.ShowDialog(); + } + + static int AscendingCompare(int i1, int i2) + { + if (i1 == i2) + return 0; + + return i2 > i1 ? 1 : -1; + } + + static int DescendingCompare(int i1, int i2) + { + if (i1 == i2) + return 0; + + return i2 < i1 ? 1 : -1; + } + + static void Area_Click(object sender) + { + Form form = sender as Form; + form.Text = "MyArea 클릭!"; + } + + static void After_Click(object sender) + { + Form form = sender as Form; + form.Text += " AfterClick 클릭!"; + } + } +} diff --git a/Delegate/Properties/AssemblyInfo.cs b/Delegate/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f6fb6d9 --- /dev/null +++ b/Delegate/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("Delegate")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Delegate")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("922045d0-45a3-4dae-81ed-ea448da1f16e")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DelegateForm/App.config b/DelegateForm/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/DelegateForm/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DelegateForm/DelegateForm.csproj b/DelegateForm/DelegateForm.csproj new file mode 100644 index 0000000..f11c867 --- /dev/null +++ b/DelegateForm/DelegateForm.csproj @@ -0,0 +1,88 @@ + + + + + Debug + AnyCPU + {F202922C-827E-48E7-B8C2-9B22B1CE9993} + WinExe + Properties + DelegateForm + DelegateForm + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + Form + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + \ No newline at end of file diff --git a/DelegateForm/Form1.Designer.cs b/DelegateForm/Form1.Designer.cs new file mode 100644 index 0000000..47fbcc9 --- /dev/null +++ b/DelegateForm/Form1.Designer.cs @@ -0,0 +1,39 @@ +namespace DelegateForm +{ + partial class Form1 + { + /// + /// 필수 디자이너 변수입니다. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 사용 중인 모든 리소스를 정리합니다. + /// + /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form 디자이너에서 생성한 코드 + + /// + /// 디자이너 지원에 필요한 메서드입니다. + /// 이 메서드의 내용을 코드 편집기로 수정하지 마십시오. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/DelegateForm/Form1.cs b/DelegateForm/Form1.cs new file mode 100644 index 0000000..ffa2347 --- /dev/null +++ b/DelegateForm/Form1.cs @@ -0,0 +1,37 @@ +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; + +namespace DelegateForm +{ + public partial class Form1 : Form + { + static MyArea area; + + public Form1() + { + InitializeComponent(); + + area = new MyArea(); + area.MyClick += Area_Click; + area.MyClick += After_Click; + area.ShowDialog(); + } + + static void Area_Click(object sender) + { + area.Text = "MyArea 클릭!"; + } + + static void After_Click(object sender) + { + area.Text += " AfterClick 클릭!"; + } + } +} diff --git a/DelegateForm/MyArea.cs b/DelegateForm/MyArea.cs new file mode 100644 index 0000000..881f9f5 --- /dev/null +++ b/DelegateForm/MyArea.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace DelegateForm +{ + class MyArea : Form + { + public delegate void ClickDelegate(object sender); + public ClickDelegate MyClick; + + public MyArea() + { + this.MouseClick += delegate { MyAreaClicked(); }; + } + + private void MyAreaClicked() + { + if (MyClick != null) + MyClick(this); + } + } +} diff --git a/DelegateForm/Program.cs b/DelegateForm/Program.cs new file mode 100644 index 0000000..802019c --- /dev/null +++ b/DelegateForm/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace DelegateForm +{ + static class Program + { + /// + /// 해당 응용 프로그램의 주 진입점입니다. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/DelegateForm/Properties/AssemblyInfo.cs b/DelegateForm/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ff57126 --- /dev/null +++ b/DelegateForm/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("DelegateForm")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DelegateForm")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("a9a35c59-1b48-40f8-a231-5e1848c5d11d")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DelegateForm/Properties/Resources.Designer.cs b/DelegateForm/Properties/Resources.Designer.cs new file mode 100644 index 0000000..bf3374b --- /dev/null +++ b/DelegateForm/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:4.0.30319.42000 +// +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. +// +//------------------------------------------------------------------------------ + +namespace DelegateForm.Properties +{ + + + /// + /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. + /// + // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder + // 클래스에서 자동으로 생성되었습니다. + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 + // ResGen을 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DelegateForm.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대한 현재 스레드의 CurrentUICulture + /// 속성을 재정의합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/DelegateForm/Properties/Resources.resx b/DelegateForm/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/DelegateForm/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DelegateForm/Properties/Settings.Designer.cs b/DelegateForm/Properties/Settings.Designer.cs new file mode 100644 index 0000000..7fb4fba --- /dev/null +++ b/DelegateForm/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DelegateForm.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/DelegateForm/Properties/Settings.settings b/DelegateForm/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/DelegateForm/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/DerivedClass/AbstractClass.cs b/DerivedClass/AbstractClass.cs new file mode 100644 index 0000000..87b04c3 --- /dev/null +++ b/DerivedClass/AbstractClass.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DerivedClass +{ + public abstract class AbstractClass + { + public abstract int GetFirst(); + public abstract int GetNext(); + } +} diff --git a/DerivedClass/App.config b/DerivedClass/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/DerivedClass/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DerivedClass/DerivedA.cs b/DerivedClass/DerivedA.cs new file mode 100644 index 0000000..0e1c741 --- /dev/null +++ b/DerivedClass/DerivedA.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DerivedClass +{ + class DerivedA : AbstractClass + { + private int no = 1; + + public override int GetFirst() + { + return no; + } + + public override int GetNext() + { + return ++no; + } + } +} diff --git a/DerivedClass/DerivedClass.csproj b/DerivedClass/DerivedClass.csproj new file mode 100644 index 0000000..72ed629 --- /dev/null +++ b/DerivedClass/DerivedClass.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {A4BA4E64-0ADE-4633-8950-2EBC94EE2A48} + Exe + Properties + DerivedClass + DerivedClass + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DerivedClass/Program.cs b/DerivedClass/Program.cs new file mode 100644 index 0000000..6232c28 --- /dev/null +++ b/DerivedClass/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DerivedClass +{ + class Program + { + static void Main(string[] args) + { + AbstractClass d1 = new DerivedA(); + DerivedA d2 = new DerivedA(); + + Console.WriteLine(d1 is AbstractClass); + Console.WriteLine(d2 is AbstractClass); + Console.WriteLine(d1 is DerivedA); + Console.WriteLine(d2 is DerivedA); + } + } +} diff --git a/DerivedClass/Properties/AssemblyInfo.cs b/DerivedClass/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..53a8c87 --- /dev/null +++ b/DerivedClass/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("DerivedClass")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DerivedClass")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("a6acc5a0-ee99-4d83-8c50-acd01b1ae125")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ExtensionMethod/App.config b/ExtensionMethod/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/ExtensionMethod/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ExtensionMethod/ExClass.cs b/ExtensionMethod/ExClass.cs new file mode 100644 index 0000000..8f930bd --- /dev/null +++ b/ExtensionMethod/ExClass.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ExtensionMethod +{ + // static 클래스 선언 필요 + public static class ExClass + { + public static string ToChangeCase(this string str) + { + StringBuilder sb = new StringBuilder(); + foreach (char ch in str) + { + if (ch >= 'A' && ch <= 'Z') + sb.Append((char)('a' + ch - 'A')); + else if (ch >= 'a' && ch <= 'z') + sb.Append((char)('A' + ch - 'a')); + else + sb.Append(ch); + } + + return sb.ToString(); + } + + public static bool Found(this string str, char ch) + { + int position = str.IndexOf(ch); + + return position >= 0; + } + } +} diff --git a/ExtensionMethod/ExtensionMethod.csproj b/ExtensionMethod/ExtensionMethod.csproj new file mode 100644 index 0000000..9f168eb --- /dev/null +++ b/ExtensionMethod/ExtensionMethod.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {7CD3988E-943A-4D3B-8863-A53E9ECC3ACA} + Exe + Properties + ExtensionMethod + ExtensionMethod + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ExtensionMethod/Program.cs b/ExtensionMethod/Program.cs new file mode 100644 index 0000000..57ed809 --- /dev/null +++ b/ExtensionMethod/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ExtensionMethod +{ + class Program + { + static void Main(string[] args) + { + string s = "This is a Test"; + + string s2 = s.ToChangeCase(); + Console.WriteLine(s2); + + bool found = s.Found('T'); + Console.WriteLine(found); + } + } +} diff --git a/ExtensionMethod/Properties/AssemblyInfo.cs b/ExtensionMethod/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..596360b --- /dev/null +++ b/ExtensionMethod/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("ExtensionMethod")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ExtensionMethod")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("99aa7004-800a-4b18-9d0a-f35a660b99f0")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Generics/App.config b/Generics/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Generics/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Generics/Generics.csproj b/Generics/Generics.csproj new file mode 100644 index 0000000..80c009d --- /dev/null +++ b/Generics/Generics.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {E29DBB57-BD91-43BA-8C39-E43FE161B099} + Exe + Properties + Generics + Generics + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Generics/MyStack.cs b/Generics/MyStack.cs new file mode 100644 index 0000000..e0af1e8 --- /dev/null +++ b/Generics/MyStack.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Generics +{ + class MyStack + { + T[] _elements; + int pos = 0; + + public MyStack() + { + _elements = new T[100]; + } + + public void Push(T element) + { + _elements[++pos] = element; + } + + public T Pop() + { + return _elements[pos--]; + } + } +} diff --git a/Generics/Program.cs b/Generics/Program.cs new file mode 100644 index 0000000..ce270e6 --- /dev/null +++ b/Generics/Program.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Generics +{ + class Program + { + static void Main(string[] args) + { + MyStack numberStack = new MyStack(); + MyStack nameStack = new MyStack(); + } + } +} diff --git a/Generics/Properties/AssemblyInfo.cs b/Generics/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5b61f4d --- /dev/null +++ b/Generics/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("Generics")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Generics")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("739e74a4-c9e1-4eb2-a397-60e7489350d0")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Generics/TypeContraintStack.cs b/Generics/TypeContraintStack.cs new file mode 100644 index 0000000..20cdc0f --- /dev/null +++ b/Generics/TypeContraintStack.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Generics +{ + /* + * + // T는 Value 타입 + class MyClass where T : struct + + // T는 Reference 타입 + class MyClass where T : class + + // T는 디폴트 생성자를 가져야 함 + class MyClass where T : new() + + // T는 MyBase의 파생클래스이어야 함 + class MyClass where T : MyBase + + // T는 IComparable 인터페이스를 가져야 함 + class MyClass where T : IComparable + + // 좀 더 복잡한 제약들 + class EmployeeList where T : Employee, + IEmployee, IComparable, new() + { + } + + // 복수 타입 파라미터 제약 + class MyClass + where T : class + where U : struct + { + } + * + */ + class TypeContraintStack where T : struct + { + T[] _elements; + int pos = 0; + + public TypeContraintStack() + { + _elements = new T[100]; + } + + public void Push(T element) + { + _elements[++pos] = element; + } + + public T Pop() + { + return _elements[pos--]; + } + } +} diff --git a/Interface/App.config b/Interface/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Interface/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Interface/IComparable.cs b/Interface/IComparable.cs new file mode 100644 index 0000000..ba89d90 --- /dev/null +++ b/Interface/IComparable.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Interface +{ + interface IComparable + { + int CompareTo(object obj); + } +} diff --git a/Interface/Interface.csproj b/Interface/Interface.csproj new file mode 100644 index 0000000..afcde26 --- /dev/null +++ b/Interface/Interface.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {AEE22835-BA48-4DEA-A49D-2DCDAAE904D1} + Exe + Properties + Interface + Interface + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interface/MyClass.cs b/Interface/MyClass.cs new file mode 100644 index 0000000..afa1403 --- /dev/null +++ b/Interface/MyClass.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Interface +{ + class MyClass : IComparable + { + private int key; + private int value; + + public int CompareTo(object obj) + { + MyClass target = obj as MyClass; + if (target == null) + throw new InvalidCastException(); + + return this.key.CompareTo(target.key); + } + } +} diff --git a/Interface/Program.cs b/Interface/Program.cs new file mode 100644 index 0000000..5a25b11 --- /dev/null +++ b/Interface/Program.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Interface +{ + class Program + { + static void Main(string[] args) + { + } + } +} diff --git a/Interface/Properties/AssemblyInfo.cs b/Interface/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..82fe3dc --- /dev/null +++ b/Interface/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("Interface")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Interface")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("701aaa75-c201-40bd-935f-9b42cc692be3")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/dotNetAdvancedGrammer.sln b/dotNetAdvancedGrammer.sln new file mode 100644 index 0000000..0531142 --- /dev/null +++ b/dotNetAdvancedGrammer.sln @@ -0,0 +1,58 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Indexer", "dotNetAdvancedGrammer\Indexer.csproj", "{A481076A-F3D9-4973-8A26-7C893D2040F8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DerivedClass", "DerivedClass\DerivedClass.csproj", "{A4BA4E64-0ADE-4633-8950-2EBC94EE2A48}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generics", "Generics\Generics.csproj", "{E29DBB57-BD91-43BA-8C39-E43FE161B099}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interface", "Interface\Interface.csproj", "{AEE22835-BA48-4DEA-A49D-2DCDAAE904D1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Delegate", "Delegate\Delegate.csproj", "{2624BEFB-1FF7-4403-8542-CE2B49BB2299}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnonymousMethod", "AnonymousMethod\AnonymousMethod.csproj", "{2940C9B1-249A-43B0-8A64-6432DBBD2714}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtensionMethod", "ExtensionMethod\ExtensionMethod.csproj", "{7CD3988E-943A-4D3B-8863-A53E9ECC3ACA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A481076A-F3D9-4973-8A26-7C893D2040F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A481076A-F3D9-4973-8A26-7C893D2040F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A481076A-F3D9-4973-8A26-7C893D2040F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A481076A-F3D9-4973-8A26-7C893D2040F8}.Release|Any CPU.Build.0 = Release|Any CPU + {A4BA4E64-0ADE-4633-8950-2EBC94EE2A48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4BA4E64-0ADE-4633-8950-2EBC94EE2A48}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4BA4E64-0ADE-4633-8950-2EBC94EE2A48}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4BA4E64-0ADE-4633-8950-2EBC94EE2A48}.Release|Any CPU.Build.0 = Release|Any CPU + {E29DBB57-BD91-43BA-8C39-E43FE161B099}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E29DBB57-BD91-43BA-8C39-E43FE161B099}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E29DBB57-BD91-43BA-8C39-E43FE161B099}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E29DBB57-BD91-43BA-8C39-E43FE161B099}.Release|Any CPU.Build.0 = Release|Any CPU + {AEE22835-BA48-4DEA-A49D-2DCDAAE904D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEE22835-BA48-4DEA-A49D-2DCDAAE904D1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEE22835-BA48-4DEA-A49D-2DCDAAE904D1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEE22835-BA48-4DEA-A49D-2DCDAAE904D1}.Release|Any CPU.Build.0 = Release|Any CPU + {2624BEFB-1FF7-4403-8542-CE2B49BB2299}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2624BEFB-1FF7-4403-8542-CE2B49BB2299}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2624BEFB-1FF7-4403-8542-CE2B49BB2299}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2624BEFB-1FF7-4403-8542-CE2B49BB2299}.Release|Any CPU.Build.0 = Release|Any CPU + {2940C9B1-249A-43B0-8A64-6432DBBD2714}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2940C9B1-249A-43B0-8A64-6432DBBD2714}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2940C9B1-249A-43B0-8A64-6432DBBD2714}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2940C9B1-249A-43B0-8A64-6432DBBD2714}.Release|Any CPU.Build.0 = Release|Any CPU + {7CD3988E-943A-4D3B-8863-A53E9ECC3ACA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7CD3988E-943A-4D3B-8863-A53E9ECC3ACA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7CD3988E-943A-4D3B-8863-A53E9ECC3ACA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7CD3988E-943A-4D3B-8863-A53E9ECC3ACA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dotNetAdvancedGrammer/App.config b/dotNetAdvancedGrammer/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/dotNetAdvancedGrammer/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/dotNetAdvancedGrammer/Indexer.csproj b/dotNetAdvancedGrammer/Indexer.csproj new file mode 100644 index 0000000..fba92cd --- /dev/null +++ b/dotNetAdvancedGrammer/Indexer.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {A481076A-F3D9-4973-8A26-7C893D2040F8} + Exe + Properties + Indexer + dotNetAdvancedGrammer + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dotNetAdvancedGrammer/IndexerClass.cs b/dotNetAdvancedGrammer/IndexerClass.cs new file mode 100644 index 0000000..aaa8945 --- /dev/null +++ b/dotNetAdvancedGrammer/IndexerClass.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Indexer +{ + class IndexerClass + { + private const int MAX = 10; + private string name; + + private int[] data = new int[MAX]; + + public int this[int index] + { + get + { + if (index < 0 || index >= MAX) + throw new IndexOutOfRangeException(); + + return data[index]; + } + set + { + if (!(index < 0 || index >= MAX)) + data[index] = value; + } + } + } +} diff --git a/dotNetAdvancedGrammer/Program.cs b/dotNetAdvancedGrammer/Program.cs new file mode 100644 index 0000000..0b4e423 --- /dev/null +++ b/dotNetAdvancedGrammer/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Indexer +{ + class Program + { + static void Main(string[] args) + { + IndexerClass obj = new IndexerClass(); + obj[1] = 1024; + int i = obj[1]; + Console.WriteLine(i); + } + } +} diff --git a/dotNetAdvancedGrammer/Properties/AssemblyInfo.cs b/dotNetAdvancedGrammer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c98954c --- /dev/null +++ b/dotNetAdvancedGrammer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("dotNetAdvancedGrammer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("dotNetAdvancedGrammer")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("5a57c5a1-3b3a-4432-bdfe-347a5893fba8")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]