Compare commits

...

7 Commits

Author SHA1 Message Date
jason.zhu ea26766337 Finished Query Syntax vs. Method Syntax 2021-02-24 16:17:42 +11:00
jason.zhu 066f46a48c Finished Using Func and Action Types 2021-02-24 15:40:04 +11:00
jason.zhu e0d20ef793 Finished Understanding Lambda Expression 2021-02-24 14:24:59 +11:00
jason.zhu 7756047de1 Finished Creating an Extension Method 2021-02-24 13:49:26 +11:00
jason.zhu 7ac104a924 Finished The Power of IEnumerable 2021-02-24 11:56:17 +11:00
jason.zhu ced8f125ee Added Jetbrain related into .gitignore 2021-02-23 23:05:27 +00:00
jason.zhu e6a2c62da6 Reorganized project 2021-02-23 23:01:09 +00:00
9 changed files with 256 additions and 28 deletions

95
.gitignore vendored
View File

@ -1,7 +1,7 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig # File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
# Created by https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,dotnetcore,executable,linux,macos,visualstudio # Created by https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,visualstudio,macos,linux,executable,dotnetcore,jetbrains+all
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,visualstudiocode,dotnetcore,executable,linux,macos,visualstudio # Edit at https://www.toptal.com/developers/gitignore?templates=windows,visualstudiocode,visualstudio,macos,linux,executable,dotnetcore,jetbrains+all
### DotnetCore ### ### DotnetCore ###
# .NET Core build folders # .NET Core build folders
@ -24,6 +24,95 @@ obj/
*.vb *.vb
*.wsf *.wsf
### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### JetBrains+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
.idea/
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
# Sonarlint plugin
.idea/sonarlint
### Linux ### ### Linux ###
*~ *~
@ -458,7 +547,7 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder # Ionide (cross platform F# VS Code tools) working folder
.ionide/ .ionide/
# End of https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,dotnetcore,executable,linux,macos,visualstudio # End of https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,visualstudio,macos,linux,executable,dotnetcore,jetbrains+all
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) # Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

View File

@ -0,0 +1,8 @@
namespace Features
{
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
}
}

View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>

20
Features/MyLinq.cs 100644
View File

@ -0,0 +1,20 @@
using System.Collections.Generic;
namespace Features
{
public static class MyLinq
{
// Implement a customized LINQ using extension
public static int MyLinqCount<T>(this IEnumerable<T> sequence)
{
// Any IEnumerable<T> instance can use this method now as extension
int count = 0;
foreach (var item in sequence)
{
count += 1;
}
return count;
}
}
}

View File

@ -0,0 +1,80 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
namespace Features
{
class Program
{
// Modelling a company in this project
static void Main(string[] args)
{
/* Generic Delegate & Lambda Expression */
Func<int, int> square = x => x*x;// Define a generic delegate functions named square for square operation
Func<int, int, int> add = (x, y) =>
{
int temp = x + y;
return temp;
};
Action<int> write = x => Console.WriteLine(x);
write(square(add(3, 5)));
/* LINQ & C# */
IEnumerable<Employee> developers = new Employee[]
{
new Employee {Id = 1, Name = "Scott"},
new Employee {Id = 2, Name = "Chris"}
};
List<Employee> sales = new List<Employee>()
{
new Employee {Id = 3, Name = "Alex"}
};
Console.WriteLine(sales.MyLinqCount());
var enumerator = developers.GetEnumerator();
while (enumerator.MoveNext())
{
Console.WriteLine(enumerator.Current.Name); // .Current return value of current enumerator
}
foreach (var person in developers)
{
Console.WriteLine();
}
foreach (var employee in developers
.Where(e => e.Name.Length == 5)
.OrderBy(e => e.Name))
{
Console.WriteLine(employee.Name);
}
// LINQ (Method syntax)
var query = developers.Where(e => e.Name.Length == 5)
.OrderBy(e => e.Name);
// LINQ (Query syntax)
var query2 = from developer in developers
where developer.Name.Length == 5
orderby developer.Name descending
select developer;
foreach (var employee in query)
{
Console.WriteLine(employee.Name);
}
foreach (var employee in query2)
{
Console.WriteLine(employee.Name);
}
}
}
}

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Introduction", "Introduction\Introduction.csproj", "{53450129-90CC-4C40-BDB3-295F60669012}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{53450129-90CC-4C40-BDB3-295F60669012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53450129-90CC-4C40-BDB3-295F60669012}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53450129-90CC-4C40-BDB3-295F60669012}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53450129-90CC-4C40-BDB3-295F60669012}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3A6B85BA-05FF-44DA-B35D-12FDDCF35AC7}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,48 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Introduction", "Introduction\Introduction.csproj", "{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Features", "Features\Features.csproj", "{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Debug|x64.ActiveCfg = Debug|Any CPU
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Debug|x64.Build.0 = Debug|Any CPU
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Debug|x86.ActiveCfg = Debug|Any CPU
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Debug|x86.Build.0 = Debug|Any CPU
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Release|Any CPU.Build.0 = Release|Any CPU
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Release|x64.ActiveCfg = Release|Any CPU
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Release|x64.Build.0 = Release|Any CPU
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Release|x86.ActiveCfg = Release|Any CPU
{AF71FD32-411A-42CD-A69F-DA60FB8E21A9}.Release|x86.Build.0 = Release|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|x64.ActiveCfg = Debug|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|x64.Build.0 = Debug|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|x86.ActiveCfg = Debug|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Debug|x86.Build.0 = Debug|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|Any CPU.Build.0 = Release|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|x64.ActiveCfg = Release|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|x64.Build.0 = Release|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|x86.ActiveCfg = Release|Any CPU
{94C9EE4C-0609-464B-9BFF-BA3EED2A7263}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal