myfootstep-blog1
myfootstep-blog1
My Foot Step
79 posts
There is always a meaning in every step
Don't wanna be here? Send us removal request.
myfootstep-blog1 · 7 years ago
Photo
Tumblr media
Uooo 🤑 udah reach the treshhold thanks google I am waiting for it #sampingan #horehore
2 notes · View notes
myfootstep-blog1 · 7 years ago
Text
C# Indexer
Menggunakan indexer akan mengijinkan kita untuk mengakses classs seperti halnya mengakses array. Ketika kita mendefinisikan indexer pada sebuah class maka class tersebut akan menjadi seperti virtual array. Kemudian kita dapat mengakses instance dari class tersebut menggunakan array access operator ( [  ]).
Sintax
Berikut ini adalah contoh untuk mendefinisikan indexer berdimensi satu
element-type this[int index] { // The get accessor. get { // return the value specified by index } // The set accessor. set { // set the value specified by index } }
Indexer hampir mirip dengan property, perbedaan mendasar antara keduanya adalah jika property hanya digunakan untuk specific data saja maka berbeda halnya dengan indexer, pada indexer digunanakan untuk memanipulasi bagian dari instance class dengan kata lain kita dapat membagi class kedalam bagian yang lebih kecil.
Pada indexer kita tidak mendefinisikan nama indexer tetapi menggunakan keyword this yang merupakan instance dari object. Berikut ini adalah contoh penggunaan indexer
using System; namespace IndexerApplication { class IndexedNames { private string[] namelist = new string[size]; static public int size = 10; public IndexedNames() { for (int i = 0; i < size; i++) namelist[i] = "N. A."; } public string this[int index] { get { string tmp; if( index >= 0 && index <= size-1 ) { tmp = namelist[index]; } else { tmp = ""; } return ( tmp ); } set { if( index >= 0 && index <= size-1 ) { namelist[index] = value; } } } static void Main(string[] args) { IndexedNames names = new IndexedNames(); names[0] = "Zara"; names[1] = "Riz"; names[2] = "Nuha"; names[3] = "Asif"; names[4] = "Davinder"; names[5] = "Sunil"; names[6] = "Rubic"; for ( int i = 0; i < IndexedNames.size; i++ ) { Console.WriteLine(names[i]); } Console.ReadKey(); } } }
Ketika program dieksekusi akan memberikan ouput sebagai berikut
Zara Riz Nuha Asif Davinder Sunil Rubic N. A. N. A. N. A.
Overloaded Indexer
Indexer juga bisa melakukan overload pada indexer dan juga bisa mempunyai parameter lebih dari satu, parameter indexer bisa berupa type selain integer. Berikut ini contoh untuk mengilustrasikan penggunaan indexer
using System; namespace IndexerApplication { class IndexedNames { private string[] namelist = new string[size]; static public int size = 10; public IndexedNames() { for (int i = 0; i < size; i++) { namelist[i] = "N. A."; } } public string this[int index] { get { string tmp; if( index >= 0 && index <= size-1 ) { tmp = namelist[index]; } else { tmp = ""; } return ( tmp ); } set { if( index >= 0 && index <= size-1 ) { namelist[index] = value; } } } public int this[string name] { get { int index = 0; while(index < size) { if (namelist[index] == name) { return index; } index++; } return index; } } static void Main(string[] args) { IndexedNames names = new IndexedNames(); names[0] = "Zara"; names[1] = "Riz"; names[2] = "Nuha"; names[3] = "Asif"; names[4] = "Davinder"; names[5] = "Sunil"; names[6] = "Rubic"; //using the first indexer with int parameter for (int i = 0; i < IndexedNames.size; i++) { Console.WriteLine(names[i]); } //using the second indexer with the string parameter Console.WriteLine(names["Nuha"]); Console.ReadKey(); } } }
Ketika program dieksekusi akan memberikan output sebagai berikut
Zara Riz Nuha Asif Davinder Sunil Rubic N. A. N. A. N. A. 2
0 notes
myfootstep-blog1 · 7 years ago
Video
instagram
Jalan sehat plus karnaval #kersan #bantul #jogja (at Special Region of Yogyakarta)
0 notes
myfootstep-blog1 · 7 years ago
Photo
Tumblr media
Masjid Agung Baitul Hakim (at Alun-alun Kota Madiun)
0 notes
myfootstep-blog1 · 7 years ago
Photo
Tumblr media
Prepare for release #testing #mykpi #closedloopsystem #mysafety #xploresolution #skdhause
0 notes
myfootstep-blog1 · 7 years ago
Photo
Tumblr media
Will available on global market, may be this week #mysafety #closedloopsystem #mykpi #skdhause #xploresolution
0 notes
myfootstep-blog1 · 7 years ago
Photo
Tumblr media
Pake terus sampe obsolete dan ancur baru ganti #macbook #apple #highsierra
0 notes
myfootstep-blog1 · 7 years ago
Photo
Tumblr media
VSPro #visualstudio
0 notes
myfootstep-blog1 · 7 years ago
Photo
Tumblr media
Riding the rooaaar....#kidsfun
0 notes
myfootstep-blog1 · 7 years ago
Photo
Tumblr media
#keluarga makasih @windra_ea
0 notes
myfootstep-blog1 · 7 years ago
Photo
Tumblr media
Learn clicking the mouse #progammer
0 notes
myfootstep-blog1 · 7 years ago
Photo
Tumblr media
Just meetup (at Lotus Mio)
0 notes
myfootstep-blog1 · 8 years ago
Photo
Tumblr media
Jangan pernah berhenti untuk percaya #muhammadalfatih
0 notes
myfootstep-blog1 · 8 years ago
Photo
Tumblr media
Santai kayak dipantai #eh (at Pantai Kukup Yogyakarta)
#eh
0 notes
myfootstep-blog1 · 8 years ago
Photo
Tumblr media
Cilok selera ciamis #cilokseleraciamis #cilokciamis #cilok #ciamis
0 notes
myfootstep-blog1 · 8 years ago
Photo
Tumblr media
Selamat menikmati hari minggu yang indah #coder #programmer #visualstudio
0 notes
myfootstep-blog1 · 8 years ago
Photo
Tumblr media
Btw good answer siri 😂 LOL #siri #apple #microsoft
0 notes