Rountines includes functions(which has return value) and procedure(which has no return)
- the reason for creating routine
// refer to https://github.com/ardalis/GuardClauses/tree/main | |
public interface IGuardClause { } | |
public class Guard : IGuardClause | |
{ | |
private Guard() { } | |
public static IGuardClause Against { get; } = new Guard(); | |
} |
// https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/ranges | |
#region Indexable Example | |
//System.Index | |
// use '^' operator: means read from end = true | |
// '^' operator requires type is countable and have indexer: | |
interface IIndexable<T>{ | |
public int Length { get; } // need public property 'Length', which has get access | |
public T this[int index] { get; } // need public indexer, which takes a single int as the argument. |
/* | |
* just for learning | |
* key concept, LinkedList | |
* refer https://blog.csdn.net/qq_16587307/article/details/104301877 | |
* refer https://medium.com/@bonnotguillaume/software-architecture-the-pipeline-design-pattern-from-zero-to-hero-b5c43d8a4e60 | |
*/ | |
namespace pipeline | |
{ | |
public class Program |
Console.WriteLine(); | |
// <-- Keep this information secure! --> | |
Console.WriteLine("UserName: {0}", Environment.UserName); | |
//this one can get domain and user name | |
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; | |
Console.WriteLine(); | |
Console.WriteLine(userName); |
# get internal ip address | |
ipconfig | |
# get external ip address | |
Invoke-WebRequest ifconfig.me |
import java.util.Stack; | |
class Program { | |
public static void main(String[] args) { | |
for(int i = 0; i <= 10; i++) { | |
System.out.print(fibonacci(i) + " "); | |
} | |
System.out.println(); | |
for(int i = 0; i <= 10; i++) { |
public class quickSort { | |
public static void main(String[] args) { | |
int[] test = new int[]{5,1,1,2,0,0}; | |
quickSortArr(test, 0, test.length-1); | |
printArr(test); | |
} | |
public static void printArr(int[] arr) { |
import java.util.function.Function; | |
import java.util.function.Predicate; | |
import java.util.regex.Pattern; | |
import java.util.stream.Stream; | |
import java.util.Arrays; | |
/* raw problem and better solution: | |
https://stackoverflow.com/questions/57836937/call-custom-static-functions-from-filter-and-map-in-java-8-stream | |
*/ | |
class Solution { |