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
91
0
Share
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
79
Unityの合同同人誌や合同商業誌を書いてる僕は感想やレビューや評価が欲しい
ryotamurohoshi
0
600
Unity 2021.1での Unityパッケージの名称変更について
ryotamurohoshi
0
840
Odin Validationはいいぞ!
ryotamurohoshi
2
1.1k
Tilemapはいいぞ!2020 〜すごいぞ、プロジェクト専用拡張Brush〜
ryotamurohoshi
0
2.5k
Unityでも、新しいC#
ryotamurohoshi
0
1.5k
Riderはいいぞ!
ryotamurohoshi
1
3.7k
Riderのススメ〜俺はRiderここが好き〜
ryotamurohoshi
1
2.7k
Unity開発者に伝えたい.NETのこと
ryotamurohoshi
4
38k
Other Decks in Technology
See All in Technology
オライリーイベント登壇資料「鉄リサイクル・産廃業界におけるAI技術実応用のカタチ」
takarasawa_
0
380
[Oracle TechNight#99] 生成AI時代のAI/ML入門 ~ AIとオラクルデータベースの関係 (前半)
oracle4engineer
PRO
2
240
鹿野さんに聞く!CSSの最新トレンド Ver.2026
tonkotsuboy_com
6
2.8k
ServiceによるKubernetes通信制御ーClusterIPを例に
miku01
1
160
多角的な視点から見たAGI
terisuke
0
130
AIと乗り切った1,500ページ超のヘルプサイト基盤刷新とさらにその先の話
mugi_uno
2
330
そのSLO 99.9%、本当に必要ですか? 〜優先度付きSLOによる責任共有の設計思想〜 / Is that 99.9% SLO really necessary? Design philosophy of shared responsibility through prioritized SLOs
vtryo
0
510
Building Production-Ready Agents Microsoft Agent Framework
_mertmetin
0
160
20260516_SecJAWS_Days
takuyay0ne
1
220
Forget technical debt
ufried
0
180
AI対話分析の夢と、汚いデータの現実 Looker / Dataplex / Dataform で実現する品質ファーストな基盤設計
waiwai2111
0
350
なぜ、私がCommunity Builderに?〜活動期間1か月半でも選出されたワケ〜
yama3133
0
120
Featured
See All Featured
Building the Perfect Custom Keyboard
takai
2
750
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
130
Visualization
eitanlees
150
17k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
230
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
210
The untapped power of vector embeddings
frankvandijk
2
1.7k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
290
Building Adaptive Systems
keathley
44
3k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
43k
Building AI with AI
inesmontani
PRO
1
970
HDC tutorial
michielstock
2
650
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ͷ׆༻໘ଟ͔ͬͨΓ͠·͢ʁ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠