Introduction
It is time for me to learn all API of C# List class. I like to figure out how to expedite my coding using C#.
Motivation
I was so surprised to read C# code written by one of senior engineers, and then I asked myself how come I never used those two APIs.
Here is the link.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution | |
{ | |
public IList<int> CircularPermutation(int n, int start) | |
{ | |
var result = new List<int>(); | |
for(int i = 0; i < Math.Pow(2, n); i++) | |
result.Add(i ^ (i >> 1)); | |
var index = result.IndexOf(start); | |
var left = result.Take(index).ToList(); | |
var right = result.Skip(index).ToList(); | |
right.AddRange(left); | |
return right; | |
} | |
} |
Here is to learn IEnumerable.Skip, IEnumerable.Take API.
Array's APIs
Array's available method and function are listed in the following, 72 options. I like to memorize all of them, and a few words are new to me. I like to get to know those methods first.
0
Add
AddRange
AsReadOnly
BinarySearch
Clear
Contains
ConvertAll
CopyTo
Exists
Find
FindAll
FindIndex
FindLast
FindLastIndex
Aggregate |
All |
Any |
AsEnumerable |
AsParallel |
AsParallel<> |
AsQuerable |
AsQuerable<> |
Average |
Average<> 2 |
Cast<> |
Clone |
Concat<> |
Contain<> |
CopyTo<> |
Count<> |
DefaultIfEmpty |
Distinct |
ElementAt |
ElementAtOrDefault 3 |
Equals |
Except<> |
FirstOrDefault<> |
First<> |
GetEnumerator |
GetHashCode |
GetLength |
GetLongLength |
GetLowerBound |
GetType 4 |
GetUpperBound |
GetType |
GetUpperBound |
GetValue |
GroupBy |
GroupJoin |
Initialize |
Intersect |
Join |
Last 5 |
LastOrDefault |
Length |
IsFixedSize |
IsReadONly |
IsSyncrhonized |
Max |
Max<> |
Min |
Min<> |
OfType<> 6 |
OrderBy<> |
OrderByDescending<> |
Rank |
Reverse<> |
Select<> |
SelectMany<> |
SequenceEqual<> |
SetValue |
Single<> |
SingleOrDefault<> 7 |
Skip<> |
SkipWhile<> |
Sum |
Sum<> |
SyncRoot |
Take<> |
TakeWhile |
ToArray |
ToDictionary |
ToList 8 |
ToLookup |
ToString |
Union<> |
Where<> |
Zip |
No comments:
Post a Comment