Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
C#のList<T>がIListを実装している件
Search
RyotaMurohoshi
January 31, 2015
Technology
92
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
C#のList<T>がIListを実装している件
2015/01/31の富山合同勉強会 .NET & Java ~ぶりしゃぶで休もう~で発表した際の資料です
※元々はSlideShareで公開していた資料です
RyotaMurohoshi
January 31, 2015
More Decks by RyotaMurohoshi
See All by RyotaMurohoshi
Tilemapのアップデートについて
ryotamurohoshi
0
87
Unityの合同同人誌や合同商業誌を書いてる僕は感想やレビューや評価が欲しい
ryotamurohoshi
0
610
Unity 2021.1での Unityパッケージの名称変更について
ryotamurohoshi
0
870
Odin Validationはいいぞ!
ryotamurohoshi
2
1.1k
Tilemapはいいぞ!2020 〜すごいぞ、プロジェクト専用拡張Brush〜
ryotamurohoshi
0
2.5k
Unityでも、新しいC#
ryotamurohoshi
0
1.5k
Riderはいいぞ!
ryotamurohoshi
1
3.8k
Riderのススメ〜俺はRiderここが好き〜
ryotamurohoshi
1
2.7k
Unity開発者に伝えたい.NETのこと
ryotamurohoshi
4
38k
Other Decks in Technology
See All in Technology
Oracle Exadata Database Service on Cloud@Customer X11M (ExaDB-C@C) サービス概要
oracle4engineer
PRO
2
8.4k
ソニー銀行におけるビジネスアジリティ向上のためのクラウドシフト戦略
srenext
0
110
型は壁、Rustでもバグを直すな、表現できなくせよ
nwiizo
13
2k
KiCAD講習会②
tutcreators
0
110
あなたの『Site』はどこですか? — xREという考え方
miyamu
0
1.2k
CIで使うClaude
iwatatomoya
0
230
知らん間に、回ってる
ming_ayami
0
400
誤解だらけの開発生産性 / Myths and Misconceptions about Developer Productivity
i35_267
1
210
「早く出す」より「事業に効く」 ── 顧客の業務サイクルから逆算するAI時代の二重ループ開発と「変化の設計者」 / devsumi2026
rakus_dev
1
190
クラウド上のデータ復旧で見落としがちな制約: 医療系 SaaS の BCP 設計から得た教訓
kakehashi
PRO
0
3.3k
Genie Ontologyは銀の弾丸かを考える / Is Genie Ontology a Silver Bullet?
nttcom
0
240
しくみを学んで使いこなそう GitHub Copilot app
torumakabe
1
210
Featured
See All Featured
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
4 Signs Your Business is Dying
shpigford
187
22k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
340
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
330
Game over? The fight for quality and originality in the time of robots
wayneb77
1
220
Writing Fast Ruby
sferik
630
63k
The Cult of Friendly URLs
andyhume
79
6.9k
New Earth Scene 8
popppiees
3
2.4k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1k
So, you think you're a good person
axbom
PRO
2
2.1k
Transcript
C#ͷList<T>͕IListΛ࣮͍ͯ͠Δ݅
ࣗݾհ
໊લɿࣨ!྄ଠ ॴଐɿFuller,'Inc.
2લ·ͰJavaͬͯ·ͨ͠ʂ AndroidΞϓϦ։ൃͬͯ·ͨ͠ɻ
ࠓC#ͬͯ·͢ʂ C#(Mono2.x)ͰUnityͰήʔϜ࡞ͬͯ·͢ʂ
ͦΜͳࢲ͕͋ΔٙΛ Ϳ͚͍ͭͨͱࢥ͍·͢ʂ
C#ͷList<T>͕IListΛ࣮͍ͯ͠Δ݅ ਖ਼IListΛ࣮͢Δඞཁ͕ͳ͍ͱࢥͬͯ·ͨ͠ ͦͯ͠ɺͪΐͬͱ͕͋Γ·͢
Կ͕͔ʁ List<string> stringList = new List<string> (); IList list =
stringList; list.Add (1); // ίϯύΠϧ௨Δ ࣮ߦ࣌ʹྫ֎ൃੜʂ List<T>ͷΠϯελϯεΛIListΠϯλʔϑΣʔεͷมʹೖ System.ArgumentExcep1on͕ൃੜ͢Δ͜ͱ͕͋Δʂ ※List<T>C#ͩͱΫϥεͰ͢
എܠΛઆ໌͠·͢
C##2.0͔ΒδΣωϦοΫ͕ಋೖ͞Ε δΣωϦοΫͳίϨΫγϣϯͷ ΫϥεɺΠϯλʔϑΣʔε͕Ճ͞Ε·ͨ͠ (System.Collec-ons.GenericԼ)
δΣωϦοΫΠϯλʔϑΣʔεͷྫɹ(໊લͷઌ಄ʹI͕ͭ͘) • IList<T> • IDic,onary<TKey,5TValue> δΣωϦοΫΫϥεͷྫɹ(ΠϯλʔϑΣʔε͡Όͳͯ͘Ϋϥε) • List<T> • Dic+onary<TKey,4TValue>
͡Ό͋ͦͷલɺC##1.01.1Ͱʁ
System.Collec,ons໊લۭؒԼͷ ඇδΣωϦοΫͳผͷίϨΫγϣϯ ྫ͑IListͱ͔IDic(onaryͱ͔ArrayListͱ͔ ͋ͱɺSystem.Collec,ons.Specialized໊લۭؒԼʹ
ϙΠϯτ C#ͷδΣωϦοΫίϨΫγϣϯͱ ඇδΣωϦοΫίϨΫγϣϯ ผͷΫϥεɾผͷΠϯλʔϑΣʔε (͜͜Javaͱҧ͏ʂ)
IListΠϯλʔϑΣʔε ͱ IList<T>ΠϯλʔϑΣʔε
IListΠϯλʔϑΣʔε ඇδΣωϦοΫͳϦετΛ࢘ΔΠϯλʔϑΣʔε • ϝιουͱϓϩύςΟͷҰྫ "*"void"Add(Object"value)"ཁૉͷՃ "*"Object"this[int"index]"{"get;"set;"}"ΠϯσΫα • ܧঝ͍ͯ͠ΔΠϯλʔϑΣʔεICollec@onͱIEnumerable
IList<T>ΠϯλʔϑΣʔε(1) δΣωϦοΫͳϦετΛ࢘ΔΠϯλʔϑΣʔε ϝιουͱϓϩύςΟͷҰྫ • void&Add(T&ietm)&ཁૉͷՃ • T&this[int&index]&{&get;&set;&}&ΠϯσΫα δΣωϦοΫͳϝιουͱϓϩύςΟʹʂ
IList<T>ΠϯλʔϑΣʔε(2) ܧঝ͍ͯ͠ΔΠϯλʔϑΣʔε • ICollec(on<T> • IEnumerable<T> • IEnumerable IListΠϯλʔϑΣʔεΛܧঝ͍ͯ͠ͳ͍ʂ
IListΠϯλʔϑΣʔεͱIList<T>ΠϯλʔϑΣʔε • ϝιουͱϓϩύςΟࣅ͍ͯΔͷ͋Δ • ඇδΣωϦοΫ͔δΣωϦοΫ͔ͱ͍͏େ͖ͳҧ͍ • ܧঝؔͳ͍ʢ͜͜ॏཁʂʣ
ϙΠϯτ IList<T>ΠϯλʔϑΣʔε࣮͢Δ͔Βͬͯɺ ඞͣIListΠϯλʔϑΣʔε࣮͢Δඞཁͳ͍
List<T>ΫϥεͲ͏ͳ͍ͬͯΔʁ
List<T>Ϋϥε͕࣮͍ͯ͠ΔΠϯλʔϑΣʔε • IList'<)͜͜ʂʂʂʂ • IList<T>'<)͋ͱ͜͜ʂ • ICollec1on • ICollec1on<T> •
IReadOnlyList<T>ɺIReadOnlyCollec1on<T> • IEnumerable<T>ɺIEnumerable
List<T>ΫϥεIList<T>Λ࣮ Ճ͑ͯඇδΣωϦοΫͳIList ࣮͍ͯͯ͠ɽɽɽ
݁Ռ͜͏ͳΔ List<string> stringList = new List<string> (); IList list =
stringList; list.Add (1); // System.ArgumentException͕ൃੜʂ ໌ࣔతͳΠϯλʔϑΣʔεͷ࣮ͳΜͪΌΒׂѪ
List<T>͕IList࣮͍ͯ͠Δͷඞཁͳ͘ͳ͍ʁ IList<T>࣮ͯ͠Δ͔ΒɺͦΕͰΑ͘ͳ͍ʁ Ή͠ΖIListअຐ͡Όͳ͍ʁ
ͳͥList<T>IListΛ ࣮͍ͯ͠Δ͔ௐͯΈͨ
stackoverflow h"p:/ /stackoverflow.com/ques5ons/6156010/why<list<implements<ilist
δΣωϦοΫ͕ಋೖ͞ΕͨC##2.0/.NET#2.0 ͕ొͨ࣌͠Λ૾͠·͠ΐ͏
200512݄8
AKB48&ܶͰॳެԋ
ͷ1ϲ݄લɺ200511݄7 .NET%2.0ϦϦʔε(wikipediaΑΓ)
C#1.0ͱ1.1Ͱ વશͯͷίʔυ͕ඇδΣωϦοΫʂʂʂ ͦͷͨΊطଘͷίʔυɺ Ҿͱͯ͠List<T>IList<T>ͱΒͳ͍ʂ
͜͜ͰIList͕׆༂ʂ
List<T>Ϋϥε IListΠϯλʔϑΣʔεΛ࣮ͯ͠Δ͓͔͛Ͱ IListΛҾʹͱΔϝιουʹList<T>ΛͤΔ
طଘͷC##1.0/1.1ͷϥΠϒϥϦͰɺ IListҾʹͱΔϝιουʹ List<T>ΛͤΔʂ
ͭ·ΓList<T>͕IListΛ࣮ͨ͠ͷɺ ඇδΣωϦοΫίϨΫγϣϯ͔ΒδΣωϦοΫίϨΫγϣϯͷ ҠߦΛεϜʔζʹߦ͏ͨΊʁ طଘࣗ࡞ϥΠϒϥϦ͕List<T>ҾʹऔΕͳ͍͔ΒΘͳ͍Λࢭ͢ΔͨΊʁ ʮIListΛҾʹͱΔϝιουʹList<T>ͤΔͳΒɺList<T>ͬͯΈΔ͔ʂʯ͕ૂ͍ʁ
Ͳ͏Ͱ͠ΐ͏ʁ ͋ͬͯ·͔͢Ͷʁ
ͦΕͱ͔ͯ͠͠ࢲ͕Βͳ͍͚ͩͰɺ IListͷ׆༻໘ଟ͔ͬͨΓ͠·͢ʁ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠