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
0
64
C#のList<T>がIListを実装している件
2015/01/31の富山合同勉強会 .NET & Java ~ぶりしゃぶで休もう~で発表した際の資料です
※元々はSlideShareで公開していた資料です
RyotaMurohoshi
January 31, 2015
Tweet
Share
More Decks by RyotaMurohoshi
See All by RyotaMurohoshi
Unityの合同同人誌や合同商業誌を書いてる僕は感想やレビューや評価が欲しい
ryotamurohoshi
0
370
Unity 2021.1での Unityパッケージの名称変更について
ryotamurohoshi
0
630
Odin Validationはいいぞ!
ryotamurohoshi
2
860
Tilemapはいいぞ!2020 〜すごいぞ、プロジェクト専用拡張Brush〜
ryotamurohoshi
0
2.3k
Unityでも、新しいC#
ryotamurohoshi
0
1.2k
Riderはいいぞ!
ryotamurohoshi
1
3.2k
Riderのススメ〜俺はRiderここが好き〜
ryotamurohoshi
1
2.2k
Unity開発者に伝えたい.NETのこと
ryotamurohoshi
4
36k
ImportedLinqのススメ
ryotamurohoshi
0
1.3k
Other Decks in Technology
See All in Technology
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
1
350
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.9k
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
310
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
490
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
0
110
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
190
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
280
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
600
AGIについてChatGPTに聞いてみた
blueb
0
130
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
Featured
See All Featured
It's Worth the Effort
3n
183
27k
Speed Design
sergeychernyshev
25
620
Bash Introduction
62gerente
608
210k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Code Reviewing Like a Champion
maltzj
520
39k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Agile that works and the tools we love
rasmusluckow
327
21k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
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ͷ׆༻໘ଟ͔ͬͨΓ͠·͢ʁ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠