Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
C#のList<T>がIListを実装している件
Search
RyotaMurohoshi
January 31, 2015
Technology
110
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
100
Unityの合同同人誌や合同商業誌を書いてる僕は感想やレビューや評価が欲しい
ryotamurohoshi
0
630
Unity 2021.1での Unityパッケージの名称変更について
ryotamurohoshi
0
920
Odin Validationはいいぞ!
ryotamurohoshi
2
1.1k
Tilemapはいいぞ!2020 〜すごいぞ、プロジェクト専用拡張Brush〜
ryotamurohoshi
0
2.6k
Unityでも、新しいC#
ryotamurohoshi
0
1.5k
Riderはいいぞ!
ryotamurohoshi
1
3.8k
Riderのススメ〜俺はRiderここが好き〜
ryotamurohoshi
1
2.8k
Unity開発者に伝えたい.NETのこと
ryotamurohoshi
4
38k
Other Decks in Technology
See All in Technology
React改造してみた
tsukina_7mochi
0
110
フィンテック養成勉強会#68
finengine
0
140
Local CI × GitHub Actions
gogutan
3
230
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
310
M5Stackで作る BLEマウス GPSログの世界
tomokusaba
PRO
0
440
Webの常識が通じないHTMLメールのダークモード
teamlab
PRO
0
130
コンテナ運用におけるネットワーク・コンテナコストの削減方法/How to Reduce Network and Container Costs in Container Operations
masakiokuda
2
300
スプシの手作業からの解脱 ~更新はClaude Codeに、見せ方と使い方はGASアプリに任せる~
kentarofujii
0
160
アウトプット初心者、半年間のふりかえり
4o1sobblue
0
440
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
200
DGX Spark でどこまでハッキングができるのか?
kash1064
3
1.4k
大型犬好きによるPugの紹介
yamanoku
1
160
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
Agile that works and the tools we love
rasmusluckow
331
22k
Music & Morning Musume
bryan
48
7.4k
Darren the Foodie - Storyboard
khoart
PRO
4
4k
Technical Leadership for Architectural Decision Making
baasie
3
600
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
220
Site-Speed That Sticks
csswizardry
13
1.6k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Large-scale JavaScript Application Architecture
addyosmani
516
110k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
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ͷ׆༻໘ଟ͔ͬͨΓ͠·͢ʁ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠