add csharp examples (#10)
This commit is contained in:
committed by
Aditya Bhargava
parent
c3396b8b0a
commit
62ed616954
2
03_recursion/csharp/01_countdown/.gitignore
vendored
Normal file
2
03_recursion/csharp/01_countdown/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
**/bin/*
|
||||
**/obj/*
|
||||
23
03_recursion/csharp/01_countdown/.vscode/launch.json
vendored
Normal file
23
03_recursion/csharp/01_countdown/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (console)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/01_countdown.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"externalConsole": false,
|
||||
"stopAtEntry": false,
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command.pickProcess}"
|
||||
}
|
||||
]
|
||||
}
|
||||
16
03_recursion/csharp/01_countdown/.vscode/tasks.json
vendored
Normal file
16
03_recursion/csharp/01_countdown/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "dotnet",
|
||||
"isShellCommand": true,
|
||||
"args": [],
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "build",
|
||||
"args": [
|
||||
"${workspaceRoot}/project.json"
|
||||
],
|
||||
"isBuildCommand": true,
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
23
03_recursion/csharp/01_countdown/Program.cs
Normal file
23
03_recursion/csharp/01_countdown/Program.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Countdown(5);
|
||||
}
|
||||
|
||||
private static void Countdown(int i)
|
||||
{
|
||||
Console.WriteLine(i);
|
||||
|
||||
// base case
|
||||
if (i <= 0) return;
|
||||
|
||||
// recursive case
|
||||
Countdown(i - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
03_recursion/csharp/01_countdown/project.json
Normal file
19
03_recursion/csharp/01_countdown/project.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"buildOptions": {
|
||||
"debugType": "portable",
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.1"
|
||||
}
|
||||
},
|
||||
"imports": "dnxcore50"
|
||||
}
|
||||
}
|
||||
}
|
||||
6598
03_recursion/csharp/01_countdown/project.lock.json
Normal file
6598
03_recursion/csharp/01_countdown/project.lock.json
Normal file
File diff suppressed because it is too large
Load Diff
2
03_recursion/csharp/02_greet/.gitignore
vendored
Normal file
2
03_recursion/csharp/02_greet/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
**/bin/*
|
||||
**/obj/*
|
||||
23
03_recursion/csharp/02_greet/.vscode/launch.json
vendored
Normal file
23
03_recursion/csharp/02_greet/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (console)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/02_greet.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"externalConsole": false,
|
||||
"stopAtEntry": false,
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command.pickProcess}"
|
||||
}
|
||||
]
|
||||
}
|
||||
16
03_recursion/csharp/02_greet/.vscode/tasks.json
vendored
Normal file
16
03_recursion/csharp/02_greet/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "dotnet",
|
||||
"isShellCommand": true,
|
||||
"args": [],
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "build",
|
||||
"args": [
|
||||
"${workspaceRoot}/project.json"
|
||||
],
|
||||
"isBuildCommand": true,
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
30
03_recursion/csharp/02_greet/Program.cs
Normal file
30
03_recursion/csharp/02_greet/Program.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Greet("adit");
|
||||
}
|
||||
|
||||
private static void Greet(string name)
|
||||
{
|
||||
Console.WriteLine($"hello, {name}!");
|
||||
Greet2(name);
|
||||
Console.WriteLine("getting ready to say bye...");
|
||||
Bye();
|
||||
}
|
||||
|
||||
private static void Greet2(string name)
|
||||
{
|
||||
Console.WriteLine($"how are you, {name}?");
|
||||
}
|
||||
|
||||
private static void Bye()
|
||||
{
|
||||
Console.WriteLine("ok bye!");
|
||||
}
|
||||
}
|
||||
}
|
||||
19
03_recursion/csharp/02_greet/project.json
Normal file
19
03_recursion/csharp/02_greet/project.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"buildOptions": {
|
||||
"debugType": "portable",
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.1"
|
||||
}
|
||||
},
|
||||
"imports": "dnxcore50"
|
||||
}
|
||||
}
|
||||
}
|
||||
6598
03_recursion/csharp/02_greet/project.lock.json
Normal file
6598
03_recursion/csharp/02_greet/project.lock.json
Normal file
File diff suppressed because it is too large
Load Diff
2
03_recursion/csharp/03_factorial/.gitignore
vendored
Normal file
2
03_recursion/csharp/03_factorial/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
**/bin/*
|
||||
**/obj/*
|
||||
23
03_recursion/csharp/03_factorial/.vscode/launch.json
vendored
Normal file
23
03_recursion/csharp/03_factorial/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (console)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/03_factorial.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"externalConsole": false,
|
||||
"stopAtEntry": false,
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command.pickProcess}"
|
||||
}
|
||||
]
|
||||
}
|
||||
16
03_recursion/csharp/03_factorial/.vscode/tasks.json
vendored
Normal file
16
03_recursion/csharp/03_factorial/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "dotnet",
|
||||
"isShellCommand": true,
|
||||
"args": [],
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "build",
|
||||
"args": [
|
||||
"${workspaceRoot}/project.json"
|
||||
],
|
||||
"isBuildCommand": true,
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
19
03_recursion/csharp/03_factorial/Program.cs
Normal file
19
03_recursion/csharp/03_factorial/Program.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(Fact(5));
|
||||
}
|
||||
|
||||
private static int Fact(int x)
|
||||
{
|
||||
if (x <= 1) return 1;
|
||||
|
||||
return x * Fact(x - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
03_recursion/csharp/03_factorial/project.json
Normal file
19
03_recursion/csharp/03_factorial/project.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"buildOptions": {
|
||||
"debugType": "portable",
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.1"
|
||||
}
|
||||
},
|
||||
"imports": "dnxcore50"
|
||||
}
|
||||
}
|
||||
}
|
||||
6598
03_recursion/csharp/03_factorial/project.lock.json
Normal file
6598
03_recursion/csharp/03_factorial/project.lock.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user