Monday, November 6, 2017

Learning Interface through C# 2000 things

Nov. 6, 2017

Introduction


I got some advice to code to interface through the code review, so I plan to spend 2 hours to go over all interface things through C# 2000 things.

Here is the snapshot:


Code to Interface


It is so interesting to know that I enjoy to go over interface learning through C# 2000 things first. In order to understand the C# array and also IEnumerable interface, I need to go over the basics of C# first.


Actionable Items


Study Abstract class Array

Nov. 7, 2017


Actionable Item

Work on C# Array abstract class study

How many interfaces are derived from?

IClonable
IList
ICollection
IEnumerable
IStructuralComparable
IStructuralEquatable


Properties


IsFixedSize
IsReadOnly
IsSynchronize
Length
LongLength
Rank
SyncRoot

Method ( 10 methods a time)

AsReadOnly<T> (T[])
BinarySearch(Array, Int32, Int32, Object)  Use IComparable interface implemented by each element of the array and by the specified value.
BinarySearch(Array, Int32, Int32, Object, IComparer) Search a range of elements in a one-dimensional sorted array for a value, using the specified IComparer interface.
BinarySearch<T> (T[], T)
BinarySearch<T>(T[], T, IComparer<T>) Searches an entire one-dimensional sorted array for a value using the specified IComparer<T> generic interface.

BinarySearch<T>(T[], Int32, Int32, T) Searches a range of elements in a one-dimensional sorted array for a value, using the IComparable<T> generic interface implemented by each element of the Array and by the specified value.

BinarySearch<T>(T[], Int32, Int32, T, IComparer<T>) Searches a range of elements in a one-dimensional sorted array for a value, using the specified IComparer<T> generic interface.

Clear(Array, Int32, Int32) Sets a range of elements in an array to the default value of each element type.

Clone()
ConstrainedCopy(Array, Int32, Array, Int32, Int32) Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. Guarantees that all changes are undone if the copy does not succeed completely.

Start to read a question:
Why array implements IList?

IEnumerable vs IList

Nov. 8, 2017

What problem does IStructuralEquatable and IStructuralComparable solve?

Nov. 9, 2017
Read C# Array source code here. I found the link in the first few paragraphs of Array document.

Read C# SorterObjectArray - mscor.lib, the link is here

No comments:

Post a Comment