├── Interviews ├── Sciata │ ├── OOPs.txt │ ├── TestSwab │ │ ├── TestSwab.csproj │ │ ├── TestSwab.sln │ │ └── Program.cs │ └── SOLID Principles.txt ├── Amazon │ ├── AmazonTest.csproj │ ├── Program.cs │ └── AmazonTest.sln ├── WayFair │ ├── CSharpBasics.csproj │ ├── .vscode │ │ ├── launch.json │ │ └── tasks.json │ ├── CSharpBasics.sln │ └── Program.cs └── SIG │ └── SIG │ ├── SIGTest.csproj │ └── Program.cs ├── CSharpAlgorithms ├── bin │ └── Debug │ │ └── CSharpAlgorithms.1.0.0.nupkg ├── CSharpAlgorithms.csproj ├── Notes.txt ├── BubbleSort.cs ├── SelectionSort.cs ├── InsertionSort.cs ├── CSharpAlgorithms.sln └── BinarySearch.cs ├── Arrays ├── CSharpBasics.csproj ├── .vscode │ ├── launch.json │ └── tasks.json ├── CSharpBasics.sln └── Program.cs ├── LINQ ├── CSharpBasics.csproj ├── .vscode │ ├── launch.json │ └── tasks.json ├── CSharpBasics.sln └── Program.cs ├── DataStructures ├── CSharpBasics.csproj ├── .vscode │ ├── launch.json │ └── tasks.json ├── CSharpBasics.sln ├── Notes.txt └── Program.cs ├── DelegatesDemo ├── DelegatesDemo.csproj ├── DelegatesDemo.sln └── Program.cs ├── Strings ├── CSharpBasics.csproj ├── .vscode │ ├── launch.json │ └── tasks.json ├── CSharpBasics.sln └── Program.cs ├── TuplesDemo ├── TuplesDemo.csproj ├── TuplesDemo.sln └── Program.cs ├── AsyncAwaitDemo ├── AsyncAwaitDemo.csproj ├── AsyncAwaitDemo.sln ├── Testing.cs └── Program.cs ├── GenericsDemo ├── GenericsDemo.csproj ├── Program.cs └── GenericsDemo.sln ├── Fundamentals ├── CarDemo │ ├── CSharpBasics.csproj │ ├── Car.cs │ ├── .vscode │ │ ├── launch.json │ │ └── tasks.json │ ├── CSharpBasics.sln │ └── Program.cs └── EmployeeDemo │ ├── EmployeeDemo.csproj │ └── Program.cs ├── UnitTestingFizzBuzz ├── UnitTestingFizzBuzz.csproj ├── Program.cs └── UnitTestingFizzBuzz.sln ├── ASPNETCoreWebAPI ├── appsettings.Development.json ├── appsettings.json ├── Models │ ├── Job.cs │ ├── Person.cs │ ├── WeatherForecast.cs │ ├── RefreshToken.cs │ ├── Role.cs │ ├── BookAuthor.cs │ ├── Sale.cs │ ├── Store.cs │ ├── Publisher.cs │ ├── Author.cs │ ├── User.cs │ ├── Book.cs │ └── BookStoresDBContext.cs ├── Program.cs ├── Notes.txt ├── Properties │ └── launchSettings.json ├── ASPNETCoreWebAPI.csproj ├── ASPNETCoreWebAPI.sln ├── ASPNETCoreWebAPI.csproj.user ├── Controllers │ ├── WeatherForecastController.cs │ ├── AuthorController.cs │ └── PeopleController.cs └── Startup.cs ├── Problem Solving - Practice ├── CodeWars │ ├── CSharpBasics.csproj │ ├── .vscode │ │ ├── launch.json │ │ └── tasks.json │ ├── CSharpBasics.sln │ └── PaginationHelper.cs ├── CodinGames │ ├── CodinGames.csproj │ ├── Program.cs │ └── CodinGames.sln ├── TestDome │ ├── TestDomePractice.csproj │ ├── Program.cs │ ├── EnumTest.cs │ ├── InheritanceTest.cs │ ├── LinqDistinct.cs │ ├── QuadraticEquation.cs │ ├── UserInputVirtualOverride.cs │ ├── TwoSumTuples.cs │ ├── AccountTest.cs │ ├── InterfaceTest.cs │ ├── Song.cs │ ├── TrainCompositionLinkedList.cs │ ├── BinarySearchTree.cs │ ├── XMLSerializerFolders.cs │ ├── RoutePlanner2DArray.cs │ ├── TestDomePractice.sln │ └── SortedSearch.cs └── LeetCode │ └── Practice │ ├── Practice.csproj │ └── Program.cs ├── UnitTestingDemo ├── UnitTestingDemo │ ├── UnitTestingDemo.csproj │ └── Program.cs ├── BankTests │ ├── BankTests.csproj │ └── BankAccountTests.cs └── UnitTestingDemo.sln ├── CSharpBasics ├── CSharpBasics.csproj ├── Program.cs └── CSharpBasics.sln ├── README.md ├── Numbers ├── Numbers.csproj └── Program.cs ├── LinkedList ├── LinkedList.csproj └── Program.cs ├── DayOfInterview ├── DayOfInterview.csproj └── Program.cs ├── NUnitTestProject ├── Tester.cs └── NUnitTestProject.csproj ├── NUnitTestProjectFizzBuzz ├── NUnitTestProjectFizzBuzz.csproj └── FizzBuzzTest.cs ├── MSTestProject ├── MSTestProject.csproj └── FizzBuzzTest.cs ├── XUnitTestProjectFizzBuzz ├── XUnitTestProjectFizzBuzz.csproj └── UnitTest1.cs ├── LICENSE ├── Notes.txt └── .gitignore /Interviews/Sciata/OOPs.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CSharpAlgorithms/bin/Debug/CSharpAlgorithms.1.0.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CuriousDrive/InterviewPreparation/HEAD/CSharpAlgorithms/bin/Debug/CSharpAlgorithms.1.0.0.nupkg -------------------------------------------------------------------------------- /Arrays/CSharpBasics.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /LINQ/CSharpBasics.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DataStructures/CSharpBasics.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DelegatesDemo/DelegatesDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Strings/CSharpBasics.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TuplesDemo/TuplesDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /AsyncAwaitDemo/AsyncAwaitDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CSharpAlgorithms/CSharpAlgorithms.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GenericsDemo/GenericsDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Interviews/Amazon/AmazonTest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Fundamentals/CarDemo/CSharpBasics.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Interviews/WayFair/CSharpBasics.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Interviews/Sciata/TestSwab/TestSwab.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /UnitTestingFizzBuzz/UnitTestingFizzBuzz.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Problem Solving - Practice/CodeWars/CSharpBasics.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Problem Solving - Practice/CodinGames/CodinGames.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /UnitTestingDemo/UnitTestingDemo/UnitTestingDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GenericsDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GenericsDemo 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Console.WriteLine("Hello World!"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/TestDomePractice.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /CSharpBasics/CSharpBasics.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TestDomePractice 4 | { 5 | class Program 6 | { 7 | static void MainDoNoCall(string[] args) 8 | { 9 | Console.WriteLine("Hello World!"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Interviews/Amazon/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AmazonTest 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | int[,] array = new int[2,2]; 10 | //Console.WriteLine(value); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # What is CodingInterviewPreparation? 2 | This repository has code samples to prepare for your C# technical interview. Samples for LINQ, Delegate, ASP.NET Web API, MSTests and mcuh more are included in this repo. You can clone this repo and go through some of the samples before your interview. 3 | -------------------------------------------------------------------------------- /Numbers/Numbers.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /LinkedList/LinkedList.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Interviews/SIG/SIG/SIGTest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/Job.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace ASPNETCoreWebAPI.Models 7 | { 8 | public partial class Job 9 | { 10 | public short JobId { get; set; } 11 | public string JobDesc { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DayOfInterview/DayOfInterview.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Fundamentals/EmployeeDemo/EmployeeDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /CSharpAlgorithms/Notes.txt: -------------------------------------------------------------------------------- 1 | Searching Algorithms 2 | 3 | 1. Linear Search => Done 4 | 2. Binary Search => Done 5 | 3. Binary Search Tree => Check Swab Interview Code 6 | 7 | Sorting Algorithms 8 | 9 | 1. Bubble Sort => Done 10 | 2. Insertion Sort => Done 11 | 3. Selection Sort => Done 12 | 4. Shell Sort => 13 | 5. Quick Sort => -------------------------------------------------------------------------------- /Problem Solving - Practice/LeetCode/Practice/Practice.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/Person.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ASPNETCoreWebAPI 4 | { 5 | public class Person 6 | { 7 | public int Id { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public DateTime DateOfBirth { get; set; } 11 | public decimal Salary { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ASPNETCoreWebAPI 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NUnitTestProject/Tester.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | using TestDomePractice; 4 | 5 | [TestFixture] 6 | public class Tester 7 | { 8 | private double epsilon = 1e-6; 9 | 10 | [Test] 11 | public void AccountCannotHaveNegativeOverdraftLimit() 12 | { 13 | AccountTest account = new AccountTest(-20); 14 | Assert.AreEqual(0, account.OverdraftLimit, epsilon); 15 | } 16 | } -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/RefreshToken.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace ASPNETCoreWebAPI.Models 7 | { 8 | public partial class RefreshToken 9 | { 10 | public int TokenId { get; set; } 11 | public int UserId { get; set; } 12 | public string Token { get; set; } 13 | public DateTime ExpiryDate { get; set; } 14 | 15 | public virtual User User { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/Role.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace ASPNETCoreWebAPI.Models 7 | { 8 | public partial class Role 9 | { 10 | public Role() 11 | { 12 | Users = new HashSet(); 13 | } 14 | 15 | public short RoleId { get; set; } 16 | public string RoleDesc { get; set; } 17 | 18 | public virtual ICollection Users { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /DayOfInterview/Program.cs: -------------------------------------------------------------------------------- 1 | Console.WriteLine( TimeRequiredToBuy(new int[] {2,3,2}, 2)); 2 | 3 | int TimeRequiredToBuy(int[] tickets, int k) { 4 | 5 | int timeTaken = 0; 6 | int counter = 0; 7 | 8 | while(tickets[k] != 0) 9 | { 10 | if(tickets[counter] > 0) 11 | { 12 | tickets[counter]--; 13 | timeTaken++; 14 | } 15 | 16 | counter++; 17 | if(counter == tickets.Length) 18 | counter = 0; 19 | } 20 | 21 | return timeTaken; 22 | } -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/BookAuthor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace ASPNETCoreWebAPI.Models 7 | { 8 | public partial class BookAuthor 9 | { 10 | public int AuthorId { get; set; } 11 | public int BookId { get; set; } 12 | public byte? AuthorOrder { get; set; } 13 | public int? RoyalityPercentage { get; set; } 14 | 15 | public virtual Author Author { get; set; } 16 | public virtual Book Book { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/EnumTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Account 4 | { 5 | [Flags] 6 | public enum Access 7 | { 8 | Modify = 1, 9 | Submit = 1, 10 | 11 | Delete = 2, 12 | Publish = 2, 13 | Comment = 2, 14 | 15 | Writer = 1, 16 | Editor = 2, 17 | 18 | Owner = 1 | 2 19 | } 20 | 21 | public static void MainDoNotCall(string[] args) 22 | { 23 | Console.WriteLine(Access.Writer.HasFlag(Access.Delete)); //Should print: "False" 24 | } 25 | } -------------------------------------------------------------------------------- /UnitTestingFizzBuzz/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace UnitTestingFizzBuzz 6 | { 7 | public class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | List numbers = Enumerable.Range(1, 100).ToList(); 12 | } 13 | 14 | public static bool IsDivisibleBy3(int num) => (num % 3 == 0) ? true : false; 15 | 16 | public static bool IsDivisibleBy5(int num) => (num % 5 == 0) ? true : false; 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CSharpBasics/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #nullable enable 4 | 5 | public struct Student 6 | { 7 | public string FirstName; 8 | public string? MiddleName; 9 | public string LastName; 10 | } 11 | 12 | public static class Program 13 | { 14 | public static void PrintStudent(Student student) 15 | { 16 | //Console.WriteLine($"First name: {student.FirstName.ToUpper()}"); 17 | Console.WriteLine($"Middle name: {student.MiddleName.ToUpper()}"); 18 | //Console.WriteLine($"Last name: {student.LastName.ToUpper()}"); 19 | } 20 | 21 | public static void Main() => PrintStudent(default); 22 | } -------------------------------------------------------------------------------- /NUnitTestProject/NUnitTestProject.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /NUnitTestProjectFizzBuzz/NUnitTestProjectFizzBuzz.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/Sale.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace ASPNETCoreWebAPI.Models 7 | { 8 | public partial class Sale 9 | { 10 | public int SaleId { get; set; } 11 | public string StoreId { get; set; } 12 | public string OrderNum { get; set; } 13 | public DateTime OrderDate { get; set; } 14 | public short Quantity { get; set; } 15 | public string PayTerms { get; set; } 16 | public int BookId { get; set; } 17 | 18 | public virtual Book Book { get; set; } 19 | public virtual Store Store { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/InheritanceTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace TestDomePractice 6 | { 7 | class InheritanceTest 8 | { 9 | public static void Main2(string[] args) 10 | { 11 | OptimizedDiskCache optimizedDiskCache = new OptimizedDiskCache(); 12 | Cache cache = (Cache)optimizedDiskCache; 13 | DiskCache diskCache = (DiskCache)cache; 14 | } 15 | } 16 | 17 | public class Cache { } 18 | public class DiskCache : Cache { } 19 | public class MemoryCache : Cache { } 20 | public class OptimizedDiskCache : DiskCache { } 21 | } 22 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/Store.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace ASPNETCoreWebAPI.Models 7 | { 8 | public partial class Store 9 | { 10 | public Store() 11 | { 12 | Sales = new HashSet(); 13 | } 14 | 15 | public string StoreId { get; set; } 16 | public string StoreName { get; set; } 17 | public string StoreAddress { get; set; } 18 | public string City { get; set; } 19 | public string State { get; set; } 20 | public string Zip { get; set; } 21 | 22 | public virtual ICollection Sales { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /MSTestProject/MSTestProject.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /UnitTestingDemo/BankTests/BankTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/LinqDistinct.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | public class MergeNames 5 | { 6 | public static string[] UniqueNames(string[] names1, string[] names2) 7 | { 8 | var names1List = names1.ToList(); 9 | names1List.AddRange(names2.ToList()); 10 | return names1List.Distinct().ToArray(); 11 | } 12 | 13 | public static void MainDoNotCall(string[] args) 14 | { 15 | string[] names1 = new string[] { "Ava", "Emma", "Olivia" }; 16 | string[] names2 = new string[] { "Olivia", "Sophia", "Emma" }; 17 | Console.WriteLine(string.Join(", ", MergeNames.UniqueNames(names1, names2))); // should print Ava, Emma, Olivia, Sophia 18 | } 19 | } -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/QuadraticEquation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class QuadraticEquation 4 | { 5 | public static Tuple FindRoots(double a, double b, double c) 6 | { 7 | double firstValue = Math.Round(((b * -1) - (Math.Sqrt(Math.Pow(b, 2) - (4 * a * c)))) / (2 * a)); 8 | double secondValue = Math.Round(((b * -1) + (Math.Sqrt(Math.Pow(b, 2) - (4 * a * c)))) / (2 * a)); 9 | 10 | return Tuple.Create(firstValue, secondValue); 11 | } 12 | 13 | public static void Main2(string[] args) 14 | { 15 | Tuple roots = QuadraticEquation.FindRoots(2, 10, 8); 16 | Console.WriteLine("Roots: " + roots.Item1 + ", " + roots.Item2); 17 | } 18 | } -------------------------------------------------------------------------------- /Problem Solving - Practice/LeetCode/Practice/Program.cs: -------------------------------------------------------------------------------- 1 | Console.WriteLine(LengthOfLongestSubstring("pwwkew")); 2 | 3 | int solution(string s, string t) { 4 | int totalCount = 0; 5 | for(int i = 0; i < s.Length; i++) 6 | { 7 | if(Char.IsDigit(s[i])) 8 | { 9 | string newString = s.Remove(i,1); 10 | if(string.Compare(newString, t) == -1) 11 | totalCount++; 12 | } 13 | } 14 | for(int i = 0; i < t.Length; i++) 15 | { 16 | if(Char.IsDigit(t[i])) 17 | { 18 | string newString = t.Remove(i,1); 19 | if(string.Compare(s,newString) == -1) 20 | totalCount++; 21 | } 22 | } 23 | return totalCount; 24 | } -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/Publisher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace ASPNETCoreWebAPI.Models 7 | { 8 | public partial class Publisher 9 | { 10 | public Publisher() 11 | { 12 | Books = new HashSet(); 13 | Users = new HashSet(); 14 | } 15 | 16 | public int PubId { get; set; } 17 | public string PublisherName { get; set; } 18 | public string City { get; set; } 19 | public string State { get; set; } 20 | public string Country { get; set; } 21 | 22 | public virtual ICollection Books { get; set; } 23 | public virtual ICollection Users { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace ASPNETCoreWebAPI 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/Author.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace ASPNETCoreWebAPI.Models 7 | { 8 | public partial class Author 9 | { 10 | public Author() 11 | { 12 | BookAuthors = new HashSet(); 13 | } 14 | 15 | public int AuthorId { get; set; } 16 | public string LastName { get; set; } 17 | public string FirstName { get; set; } 18 | public string Phone { get; set; } 19 | public string Address { get; set; } 20 | public string City { get; set; } 21 | public string State { get; set; } 22 | public string Zip { get; set; } 23 | public string EmailAddress { get; set; } 24 | 25 | public virtual ICollection BookAuthors { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/UserInputVirtualOverride.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class UserInputVirtualOverride 4 | { 5 | public static void Main2(string[] args) 6 | { 7 | TextInput input = new NumericInput(); 8 | input.Add('1'); 9 | input.Add('a'); 10 | input.Add('0'); 11 | Console.WriteLine(input.GetValue()); 12 | } 13 | } 14 | 15 | public class TextInput 16 | { 17 | public string Value { get; set; } 18 | public virtual void Add(char c) 19 | { 20 | Value += c; 21 | } 22 | 23 | public string GetValue() 24 | { 25 | return Value; 26 | } 27 | } 28 | 29 | public class NumericInput : TextInput 30 | { 31 | public override void Add(char c) 32 | { 33 | if(Char.IsDigit(c)) 34 | { 35 | base.Add(c); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Notes.txt: -------------------------------------------------------------------------------- 1 | Observations of ASP.NET Core Web API => 2 | 3 | Areas to focus on would be the following => 4 | 5 | 1. Creating controller from VS and executing the HTTP methods - Done 6 | 2. Need to read the both the MS Docs article to understand it's behavior 7 | 3. Routing is the most important thing in the Web API 8 | 4. Asynchronous programming => Done 9 | 5. Create a controller from the scratch and understand the challenges => Done 10 | 6. Understand how IActionResult works and the return types for the web api => Done 11 | 7. Also check out the parameter passing for the web api => Done 12 | 13 | 14 | Some notes about ActionResult and IActionResult 15 | IActionResults are used to send the HTTP status code back to the clients, so that 16 | it is easier for clients to handle those error 17 | You can use ActionResult to pass your objects with the response -------------------------------------------------------------------------------- /UnitTestingDemo/BankTests/BankAccountTests.cs: -------------------------------------------------------------------------------- 1 | using BankAccountNS; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace BankTests 8 | { 9 | [TestClass] 10 | public class BankAccountTests 11 | { 12 | [TestMethod] 13 | public void CheckCreditAndDebit() 14 | { 15 | // Arrange 16 | double beginningBalance = 11.99; 17 | double debitAmount = 4.55; 18 | double expected = 7.44; 19 | BankAccount account = new BankAccount("Mr. Bryan Walton", beginningBalance); 20 | 21 | // Act 22 | account.Debit(debitAmount); 23 | 24 | // Assert 25 | double actual = account.Balance; 26 | Assert.AreEqual(expected, actual, 0.001, "Account not debited correctly"); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/TwoSumTuples.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | class TwoSum 6 | { 7 | public static Tuple FindTwoSum(IList list, int sum) 8 | { 9 | //3, 1, 5, 7, 5, 9 => 10 10 | for (int i = 0; i < list.Count(); i++) 11 | { 12 | if (list[i] > sum) 13 | continue; 14 | for(int j = 0; j < list.Count(); j++) 15 | { 16 | if(i != j && list[i] + list[j] == sum) 17 | return Tuple.Create(i, j); 18 | } 19 | } 20 | return null; 21 | } 22 | 23 | public static void Main2(string[] args) 24 | { 25 | Tuple indices = FindTwoSum(new List() { 3, 1, 5, 7, 5, 9 }, 10); 26 | if (indices != null) 27 | { 28 | Console.WriteLine(indices.Item1 + " " + indices.Item2); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:50018", 8 | "sslPort": 44321 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "swagger", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "ASPNETCoreWebAPI": { 21 | "commandName": "Project", 22 | "dotnetRunMessages": "true", 23 | "launchBrowser": true, 24 | "launchUrl": "swagger", 25 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CSharpAlgorithms/BubbleSort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSharpAlgorithms 6 | { 7 | public class BubbleSort 8 | { 9 | static void Main() 10 | { 11 | int[] numbers = new int[] { 33, 56, 12, 78, 23, 90, 34, 89, 45, 67, 35 }; 12 | Console.WriteLine(String.Join(" ",Sort(numbers))); 13 | } 14 | 15 | private static int[] Sort(int[] numbers) 16 | { 17 | for(int i =0; i < numbers.Length; i++) 18 | { 19 | for(int j = 0; j < numbers.Length; j++) 20 | { 21 | if(numbers[i] < numbers[j]) 22 | { 23 | int temp = numbers[j]; 24 | numbers[j] = numbers[i]; 25 | numbers[i] = temp; 26 | } 27 | } 28 | } 29 | return numbers; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace ASPNETCoreWebAPI.Models 7 | { 8 | public partial class User 9 | { 10 | public User() 11 | { 12 | RefreshTokens = new HashSet(); 13 | } 14 | 15 | public int UserId { get; set; } 16 | public string EmailAddress { get; set; } 17 | public string Password { get; set; } 18 | public string Source { get; set; } 19 | public string FirstName { get; set; } 20 | public string MiddleName { get; set; } 21 | public string LastName { get; set; } 22 | public short RoleId { get; set; } 23 | public int PubId { get; set; } 24 | public DateTime? HireDate { get; set; } 25 | 26 | public virtual Publisher Pub { get; set; } 27 | public virtual Role Role { get; set; } 28 | public virtual ICollection RefreshTokens { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Problem Solving - Practice/CodinGames/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class Program 5 | { 6 | public static void Main(string[] args) 7 | { 8 | //we need to find most recurring substrings in the string 9 | 10 | //The substring "string" exists twice => string 11 | //Peter Piper picked a peck of pickled pepper pipes. => er pipe 12 | //Is this thing on? => is thi 13 | //I saw Susie sitting in a shoe shine shop. Where she sits she shines, and where she shines she sits. => where she s 14 | //Subdermatoglyphic => None 15 | //Test this test => test 16 | 17 | string text = "The substring string exists twice"; 18 | 19 | for (int i = 0; i < text.Length; i++) 20 | { 21 | for(int j = 0; j < text.Length; j++) 22 | { 23 | if(j-i+1 > 0) 24 | Console.WriteLine(text.Substring(i,j-i+1)); 25 | } 26 | } 27 | 28 | } 29 | } -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/AccountTest.cs: -------------------------------------------------------------------------------- 1 | namespace TestDomePractice 2 | { 3 | public class AccountTest 4 | { 5 | public double Balance { get; private set; } 6 | public double OverdraftLimit { get; private set; } 7 | 8 | public AccountTest(double overdraftLimit) 9 | { 10 | this.OverdraftLimit = overdraftLimit > 0 ? overdraftLimit : 0; 11 | this.Balance = 0; 12 | } 13 | 14 | public bool Deposit(double amount) 15 | { 16 | if (amount >= 0) 17 | { 18 | this.Balance += amount; 19 | return true; 20 | } 21 | return false; 22 | } 23 | 24 | public bool Withdraw(double amount) 25 | { 26 | if (this.Balance - amount >= -this.OverdraftLimit && amount >= 0) 27 | { 28 | this.Balance -= amount; 29 | return true; 30 | } 31 | return false; 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /CSharpAlgorithms/SelectionSort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSharpAlgorithms 6 | { 7 | public class SelectionSort 8 | { 9 | static void Main2() 10 | { 11 | int[] numbers = new int[] { 33, 56, 12, 78, 23, 90, 34, 89, 45, 67, 35 }; 12 | Console.WriteLine(String.Join(" ", Sort(numbers))); 13 | } 14 | 15 | private static int[] Sort(int[] numbers) 16 | { 17 | for(int i = 0; i < numbers.Length-1; i++) 18 | { 19 | int min_indx = i; 20 | for(int j = i + 1; j < numbers.Length; j++) 21 | { 22 | if (numbers[min_indx] > numbers[j]) 23 | min_indx = j; 24 | } 25 | 26 | int temp = numbers[i]; 27 | numbers[i] = numbers[min_indx]; 28 | numbers[min_indx] = temp; 29 | } 30 | 31 | return numbers; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/Book.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace ASPNETCoreWebAPI.Models 7 | { 8 | public partial class Book 9 | { 10 | public Book() 11 | { 12 | BookAuthors = new HashSet(); 13 | Sales = new HashSet(); 14 | } 15 | 16 | public int BookId { get; set; } 17 | public string Title { get; set; } 18 | public string Type { get; set; } 19 | public int PubId { get; set; } 20 | public decimal? Price { get; set; } 21 | public decimal? Advance { get; set; } 22 | public int? Royalty { get; set; } 23 | public int? YtdSales { get; set; } 24 | public string Notes { get; set; } 25 | public DateTime PublishedDate { get; set; } 26 | 27 | public virtual Publisher Pub { get; set; } 28 | public virtual ICollection BookAuthors { get; set; } 29 | public virtual ICollection Sales { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /LinkedList/Program.cs: -------------------------------------------------------------------------------- 1 | ListNode listNode1 = new ListNode(); 2 | listNode1.Value = 1; 3 | 4 | ListNode listNode2 = new ListNode(); 5 | listNode2.Value = 2; 6 | listNode1.Next = listNode2; 7 | 8 | ListNode listNode4 = new ListNode(); 9 | listNode4.Value = 4; 10 | listNode2.Next = listNode4; 11 | 12 | // Inserting 13 | while(listNode1 != null) 14 | { 15 | Console.WriteLine(listNode1.Value); 16 | 17 | if(listNode1.Value == 2) 18 | { 19 | ListNode newListNode = new ListNode(); 20 | newListNode.Value = 3; 21 | 22 | newListNode.Next = listNode1.Next; 23 | listNode1 = newListNode; 24 | } 25 | else 26 | listNode1 = listNode1.Next; 27 | } 28 | 29 | // Skipping/Removing 30 | while(listNode1 != null) 31 | { 32 | Console.WriteLine(listNode1.Value); 33 | if(listNode1.Value == 1) 34 | listNode1.Next = listNode1.Next.Next; 35 | else 36 | listNode1 = listNode1.Next; 37 | } 38 | 39 | public class ListNode 40 | { 41 | public int Value {get; set;} 42 | public ListNode Next {get; set;} 43 | } -------------------------------------------------------------------------------- /XUnitTestProjectFizzBuzz/XUnitTestProjectFizzBuzz.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | all 15 | 16 | 17 | runtime; build; native; contentfiles; analyzers; buildtransitive 18 | all 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /CSharpAlgorithms/InsertionSort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSharpAlgorithms 6 | { 7 | class InsertionSort 8 | { 9 | static void Main2() 10 | { 11 | int[] numbers = new int[] { 33, 56, 12, 78, 23, 90, 34, 89, 45, 67, 35 }; 12 | Console.WriteLine(String.Join(" ", Sort(numbers))); 13 | } 14 | 15 | private static int[] Sort(int[] numbers) 16 | { 17 | //33, 56, 12, 78, 23, 90, 34, 89, 45, 67, 35 18 | 19 | for(int i = 0; i < numbers.Length; i++) 20 | { 21 | for(int j = 0; j < i; j++) 22 | { 23 | if(numbers[i] < numbers[j]) 24 | { 25 | int temp = numbers[i]; 26 | numbers[i] = numbers[j]; 27 | numbers[j] = temp; 28 | break; 29 | } 30 | } 31 | } 32 | return numbers; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/InterfaceTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System; 3 | 4 | public class AlertService 5 | { 6 | private readonly IAlertDAO storage; 7 | 8 | public AlertService(IAlertDAO alertDAO) 9 | { 10 | storage = alertDAO; 11 | } 12 | 13 | public Guid RaiseAlert() 14 | { 15 | return this.storage.AddAlert(DateTime.Now); 16 | } 17 | 18 | public DateTime GetAlertTime(Guid id) 19 | { 20 | return this.storage.GetAlert(id); 21 | } 22 | } 23 | 24 | public interface IAlertDAO 25 | { 26 | Guid AddAlert(DateTime time); 27 | DateTime GetAlert(Guid id); 28 | } 29 | 30 | public class AlertDAO : IAlertDAO 31 | { 32 | private readonly Dictionary alerts = new Dictionary(); 33 | 34 | public Guid AddAlert(DateTime time) 35 | { 36 | Guid id = Guid.NewGuid(); 37 | this.alerts.Add(id, time); 38 | return id; 39 | } 40 | 41 | public DateTime GetAlert(Guid id) 42 | { 43 | return this.alerts[id]; 44 | } 45 | } -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/Song.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class Song 5 | { 6 | private string name; 7 | public Song NextSong { get; set; } 8 | 9 | public Song(string name) 10 | { 11 | this.name = name; 12 | } 13 | 14 | public bool IsRepeatingPlaylist() 15 | { 16 | List songsPlayed = new List(); 17 | Song currentSong = this; 18 | while(currentSong != null && currentSong.NextSong != null) 19 | { 20 | if(songsPlayed.Contains(currentSong.name)) 21 | { 22 | return true; 23 | } 24 | 25 | songsPlayed.Add(currentSong.name); 26 | currentSong = currentSong.NextSong; 27 | } 28 | return false; 29 | } 30 | 31 | public static void Main2(string[] args) 32 | { 33 | Song first = new Song("Hello"); 34 | Song second = new Song("Eye of the tiger"); 35 | 36 | first.NextSong = second; 37 | second.NextSong = null; 38 | 39 | Console.WriteLine(first.IsRepeatingPlaylist()); 40 | } 41 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Curious Drive 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Fundamentals/CarDemo/Car.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CSharpBasics 6 | { 7 | abstract class Vehicle : IVehicle, IVehicle2 8 | { 9 | public string Brand { get; set; } 10 | public string Type { get; set; } 11 | public int Year { get; set; } 12 | public decimal Price { get; set; } 13 | public abstract void Honk(); 14 | } 15 | 16 | interface IVehicle 17 | { 18 | void Honk(); 19 | } 20 | 21 | interface IVehicle2 22 | { 23 | 24 | } 25 | 26 | [Flags] 27 | enum CarTypes 28 | { 29 | Sedan = 1, 30 | HatchBack = 3, 31 | SUV = 2 32 | } 33 | 34 | class Car : Vehicle 35 | { 36 | public bool IndicatorState { get; set; } 37 | public override void Honk() 38 | { 39 | Console.WriteLine("Beep beep"); 40 | } 41 | } 42 | 43 | class Crane : Vehicle 44 | { 45 | public int RotaryPosition { get; set; } 46 | 47 | public override void Honk() 48 | { 49 | Console.WriteLine("Boop boop"); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/TrainCompositionLinkedList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class TrainComposition 5 | { 6 | LinkedList currentTrain = new LinkedList(); 7 | public void AttachWagonFromLeft(int wagonId) 8 | { 9 | currentTrain.AddFirst(wagonId); 10 | } 11 | public void AttachWagonFromRight(int wagonId) 12 | { 13 | currentTrain.AddLast(wagonId); 14 | } 15 | public int DetachWagonFromLeft() 16 | { 17 | int firstItem = currentTrain.First.Value; 18 | currentTrain.RemoveFirst(); 19 | return firstItem; 20 | } 21 | public int DetachWagonFromRight() 22 | { 23 | int lastItem = currentTrain.Last.Value; 24 | currentTrain.RemoveLast(); 25 | return lastItem; 26 | } 27 | public static void Main2(string[] args) 28 | { 29 | TrainComposition train = new TrainComposition(); 30 | train.AttachWagonFromLeft(7); 31 | train.AttachWagonFromLeft(13); 32 | Console.WriteLine(train.DetachWagonFromRight()); // 7 33 | Console.WriteLine(train.DetachWagonFromLeft()); // 13 34 | } 35 | } -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/ASPNETCoreWebAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Fundamentals/EmployeeDemo/Program.cs: -------------------------------------------------------------------------------- 1 | Employee employee = new CEO(); 2 | employee.EnterBuilding("AXNF"); 3 | employee.CalculateBonus(); 4 | 5 | interface IPerson 6 | { 7 | int GetAge(); 8 | string GetFullName(); 9 | } 10 | 11 | public class Person : IPerson 12 | { 13 | public int FirstName { get; set; } 14 | public int LastName { get; set; } 15 | public DateTime DateOfBirth { get; set; } 16 | 17 | public int GetAge() => DateTime.Now.Year - DateOfBirth.Year; 18 | public string GetFullName() => $"{FirstName} {LastName}"; 19 | } 20 | 21 | public abstract class Employee : Person 22 | { 23 | public virtual void EnterBuilding(string accessCode) 24 | => Console.WriteLine("Employee is entering the building"); 25 | 26 | public abstract int CalculateBonus(); 27 | } 28 | 29 | public class CEO : Employee 30 | { 31 | public override int CalculateBonus() 32 | { 33 | Console.WriteLine("Calculating bonus for \"CEO\""); 34 | return 100; 35 | } 36 | 37 | public override void EnterBuilding(string accessCode) 38 | { 39 | base.EnterBuilding(accessCode); 40 | Console.WriteLine("CEO is entering the building"); 41 | } 42 | } -------------------------------------------------------------------------------- /Arrays/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CSharpBasics.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach", 24 | "processId": "${command:pickProcess}" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /LINQ/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CSharpBasics.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach", 24 | "processId": "${command:pickProcess}" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /LINQ/CSharpBasics.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30503.244 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpBasics", "CSharpBasics.csproj", "{76EEAA04-A478-43A9-A9CD-4204B831DAD4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A08DAA29-5CAD-4343-9C55-1AFC266E30E3} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Strings/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CSharpBasics.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach", 24 | "processId": "${command:pickProcess}" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /TuplesDemo/TuplesDemo.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TuplesDemo", "TuplesDemo.csproj", "{1E71C10C-44F9-432F-A9A9-E1CF37D4E00A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1E71C10C-44F9-432F-A9A9-E1CF37D4E00A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1E71C10C-44F9-432F-A9A9-E1CF37D4E00A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1E71C10C-44F9-432F-A9A9-E1CF37D4E00A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1E71C10C-44F9-432F-A9A9-E1CF37D4E00A}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {52D5730C-3EA2-4922-A2D7-880532DBCB9A} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Arrays/CSharpBasics.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30503.244 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpBasics", "CSharpBasics.csproj", "{4A39F5DD-7405-4BE4-9AC3-3C7D7A9C6FA5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {4A39F5DD-7405-4BE4-9AC3-3C7D7A9C6FA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {4A39F5DD-7405-4BE4-9AC3-3C7D7A9C6FA5}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {4A39F5DD-7405-4BE4-9AC3-3C7D7A9C6FA5}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {4A39F5DD-7405-4BE4-9AC3-3C7D7A9C6FA5}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {4C1AC89D-F8FF-4260-AE89-08D47C2EC7FE} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /DataStructures/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CSharpBasics.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach", 24 | "processId": "${command:pickProcess}" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /Strings/CSharpBasics.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30503.244 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpBasics", "CSharpBasics.csproj", "{9B14B839-67BD-41C8-94D8-306DB1D8A1F1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {9B14B839-67BD-41C8-94D8-306DB1D8A1F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {9B14B839-67BD-41C8-94D8-306DB1D8A1F1}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {9B14B839-67BD-41C8-94D8-306DB1D8A1F1}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {9B14B839-67BD-41C8-94D8-306DB1D8A1F1}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {03AC0ACC-BD79-4826-9D33-D80A01E147A4} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /CSharpBasics/CSharpBasics.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBasics", "CSharpBasics.csproj", "{E07D368D-E3E7-4C64-A501-898F36A3E826}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {E07D368D-E3E7-4C64-A501-898F36A3E826}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {E07D368D-E3E7-4C64-A501-898F36A3E826}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {E07D368D-E3E7-4C64-A501-898F36A3E826}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {E07D368D-E3E7-4C64-A501-898F36A3E826}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {F1F80B1E-CA87-46A0-BD7A-6805B9843E47} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /DataStructures/CSharpBasics.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30503.244 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpBasics", "CSharpBasics.csproj", "{76EEAA04-A478-43A9-A9CD-4204B831DAD4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A08DAA29-5CAD-4343-9C55-1AFC266E30E3} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Fundamentals/CarDemo/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CSharpBasics.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach", 24 | "processId": "${command:pickProcess}" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /GenericsDemo/GenericsDemo.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenericsDemo", "GenericsDemo.csproj", "{28E862F8-FADF-4748-9DAD-139274C4DB99}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {28E862F8-FADF-4748-9DAD-139274C4DB99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {28E862F8-FADF-4748-9DAD-139274C4DB99}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {28E862F8-FADF-4748-9DAD-139274C4DB99}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {28E862F8-FADF-4748-9DAD-139274C4DB99}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {C953FAD7-8C58-45B9-86BE-2E8F5F8BEE11} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Interviews/Amazon/AmazonTest.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AmazonTest", "AmazonTest.csproj", "{2B578155-CB2D-4157-A41B-09AC08BC32A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2B578155-CB2D-4157-A41B-09AC08BC32A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2B578155-CB2D-4157-A41B-09AC08BC32A3}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2B578155-CB2D-4157-A41B-09AC08BC32A3}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2B578155-CB2D-4157-A41B-09AC08BC32A3}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {3FDF6D93-0093-43C6-8790-391AFBD00C93} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Interviews/Sciata/TestSwab/TestSwab.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSwab", "TestSwab.csproj", "{195247C3-144C-4502-AEB1-83428258C3F8}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {195247C3-144C-4502-AEB1-83428258C3F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {195247C3-144C-4502-AEB1-83428258C3F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {195247C3-144C-4502-AEB1-83428258C3F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {195247C3-144C-4502-AEB1-83428258C3F8}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {2635F172-6FA1-4705-A83A-3DDD97529C9E} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Interviews/WayFair/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CSharpBasics.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach", 24 | "processId": "${command:pickProcess}" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /AsyncAwaitDemo/AsyncAwaitDemo.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsyncAwaitDemo", "AsyncAwaitDemo.csproj", "{C7E8EB5A-751A-417E-A7A8-823F36C1B81D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C7E8EB5A-751A-417E-A7A8-823F36C1B81D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {C7E8EB5A-751A-417E-A7A8-823F36C1B81D}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {C7E8EB5A-751A-417E-A7A8-823F36C1B81D}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {C7E8EB5A-751A-417E-A7A8-823F36C1B81D}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {298921FB-327C-4D01-8B63-900A395452FC} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /DelegatesDemo/DelegatesDemo.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DelegatesDemo", "DelegatesDemo.csproj", "{61A8F3F7-C51B-4234-A920-947CE5F5C6D0}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {61A8F3F7-C51B-4234-A920-947CE5F5C6D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {61A8F3F7-C51B-4234-A920-947CE5F5C6D0}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {61A8F3F7-C51B-4234-A920-947CE5F5C6D0}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {61A8F3F7-C51B-4234-A920-947CE5F5C6D0}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {FDA83444-4BAD-43DB-80A1-E59F66F45D1B} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Interviews/WayFair/CSharpBasics.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30503.244 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpBasics", "CSharpBasics.csproj", "{76EEAA04-A478-43A9-A9CD-4204B831DAD4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A08DAA29-5CAD-4343-9C55-1AFC266E30E3} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Fundamentals/CarDemo/CSharpBasics.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30503.244 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpBasics", "CSharpBasics.csproj", "{76EEAA04-A478-43A9-A9CD-4204B831DAD4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A08DAA29-5CAD-4343-9C55-1AFC266E30E3} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/ASPNETCoreWebAPI.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASPNETCoreWebAPI", "ASPNETCoreWebAPI.csproj", "{2315EC06-6094-46F7-A3EE-01AF91220CBA}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2315EC06-6094-46F7-A3EE-01AF91220CBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2315EC06-6094-46F7-A3EE-01AF91220CBA}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2315EC06-6094-46F7-A3EE-01AF91220CBA}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2315EC06-6094-46F7-A3EE-01AF91220CBA}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {D8D6494C-60ED-4C6E-BF57-DCDEF72FC280} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /CSharpAlgorithms/CSharpAlgorithms.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpAlgorithms", "CSharpAlgorithms.csproj", "{E4F6CE99-CD09-47FE-A916-6E3823A34467}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {E4F6CE99-CD09-47FE-A916-6E3823A34467}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {E4F6CE99-CD09-47FE-A916-6E3823A34467}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {E4F6CE99-CD09-47FE-A916-6E3823A34467}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {E4F6CE99-CD09-47FE-A916-6E3823A34467}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {7FA94733-C9DF-4D92-B462-95AB7FAE7C23} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Interviews/Sciata/SOLID Principles.txt: -------------------------------------------------------------------------------- 1 | Single Reponsibility Principle => 2 | Creating child classes such a way that we don't have to change one class for everything. 3 | The class will be changed only when there is a reason for it change. 4 | Creating classes for it's responsibility 5 | 6 | 7 | Open/Closed Principle => 8 | A class or module is open for extension but closed for modification. 9 | Creating a interfaces for classes and then injecting the interfaces than the concrete implementation. 10 | 11 | 12 | Liskov Substitution Principle => 13 | Making use of abstract classes. Also I would reprensent this as abstraction in the oops concepts 14 | 15 | 16 | Interface Segregation Principle => 17 | You should create an interface for a particular reposibilty. and implement those in your classes. 18 | this could be refered to as polymorphism in oops concepts 19 | If you have made more interfaces than classes than you have gone far 20 | 21 | 22 | Dependency Inversion Principle => 23 | This is dependency injection in asp.net core. 24 | You can create abstractions for you concrete classes so that you can swap them if you needed to upgrade to another service. 25 | This helps you decouple the concrete implementation from abtractions 26 | -------------------------------------------------------------------------------- /Problem Solving - Practice/CodeWars/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CSharpBasics.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach", 24 | "processId": "${command:pickProcess}" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /Problem Solving - Practice/CodinGames/CodinGames.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodinGames", "CodinGames.csproj", "{6B2CE3FB-464A-4C67-8F8F-CCACEE46B7F7}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {6B2CE3FB-464A-4C67-8F8F-CCACEE46B7F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {6B2CE3FB-464A-4C67-8F8F-CCACEE46B7F7}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {6B2CE3FB-464A-4C67-8F8F-CCACEE46B7F7}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {6B2CE3FB-464A-4C67-8F8F-CCACEE46B7F7}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {65636F9C-B059-409B-8BC8-34A54BDAC7B6} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Problem Solving - Practice/CodeWars/CSharpBasics.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30503.244 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpBasics", "CSharpBasics.csproj", "{76EEAA04-A478-43A9-A9CD-4204B831DAD4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {76EEAA04-A478-43A9-A9CD-4204B831DAD4}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A08DAA29-5CAD-4343-9C55-1AFC266E30E3} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/BinarySearchTree.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TestDomePractice 4 | { 5 | public class Node 6 | { 7 | public int Value { get; set; } 8 | public Node Left { get; set; } 9 | public Node Right { get; set; } 10 | public Node(int value, Node left, Node right) 11 | { 12 | Value = value; 13 | if (left.Value <= value) 14 | Left = left; 15 | if (right.Value > value) 16 | Right = right; 17 | if (right.Value <= value) 18 | Left = right; 19 | if (left.Value > value) 20 | Right = left; 21 | } 22 | } 23 | 24 | public class BinarySearchTree 25 | { 26 | public static bool Contains(Node root, int value) 27 | { 28 | throw new NotImplementedException("Waiting to be implemented."); 29 | } 30 | 31 | public static void Main2(string[] args) 32 | { 33 | Node n1 = new Node(1, null, null); 34 | Node n3 = new Node(3, null, null); 35 | Node n2 = new Node(2, n1, n3); 36 | 37 | Console.WriteLine(Contains(n2, 3)); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/ASPNETCoreWebAPI.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MvcControllerEmptyScaffolder 5 | root/Common/MVC/Controller 6 | 600 7 | True 8 | False 9 | True 10 | 11 | ASPNETCoreWebAPI.Models.BookStoresDBContext 12 | False 13 | False 14 | 15 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/XMLSerializerFolders.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml; 4 | 5 | public class Folders 6 | { 7 | public static IEnumerable FolderNames(string xml, char startingLetter) 8 | { 9 | XmlDocument xmlDocument = new XmlDocument(); 10 | xmlDocument.LoadXml(xml); 11 | XmlElement xmlElement = xmlDocument.DocumentElement; 12 | XmlNodeList xmlNodeList = xmlElement.SelectNodes("*"); 13 | Console.WriteLine(xmlElement.Attributes["name"].Value); 14 | foreach(XmlNode item in xmlNodeList) 15 | { 16 | Console.WriteLine(item.Attributes["name"].Value); 17 | } 18 | return new List(); 19 | } 20 | 21 | public static void Main2(string[] args) 22 | { 23 | string xml = 24 | "" + 25 | "" + 26 | "" + 27 | "" + 28 | "" + 29 | "" + 30 | ""; 31 | 32 | foreach (string name in Folders.FolderNames(xml, 'u')) 33 | Console.WriteLine(name); 34 | } 35 | } -------------------------------------------------------------------------------- /Numbers/Program.cs: -------------------------------------------------------------------------------- 1 | // Max Integer 2 | // var maxIntValue = Int32.MaxValue; 3 | // var minIntValue = Int32.MinValue; 4 | 5 | // Console.WriteLine("MaxValue : " + maxIntValue); 6 | // Console.WriteLine("MinValue : " + minIntValue); 7 | 8 | // Max double 9 | // var maxValue = Double.MaxValue; 10 | // var minValue = Double.MinValue; 11 | 12 | // Console.WriteLine("MaxValue : " + maxValue); 13 | // Console.WriteLine("MinValue : " + minValue); 14 | 15 | // dividing the numbers 16 | // float e = 19; 17 | // float f = 23; 18 | // float g = 8; 19 | // float h = (e + f) / g; 20 | // Console.WriteLine(h); 21 | 22 | // Using F, D and M in front of numbers 23 | // float flt = 1F/3; 24 | // double dbl = 1D/3; 25 | // decimal dcm = 1M/3; 26 | // Console.WriteLine("float: {0} double: {1} decimal: {2}", flt, dbl, dcm); 27 | 28 | // Calculating Percentage 29 | // int score = 23; 30 | // int total = 100; 31 | 32 | // double percentage = score/(double)total; 33 | 34 | // Console.WriteLine(percentage); 35 | 36 | // Calculating Interest 37 | 38 | // int debt = 555; 39 | // int interest = 123; 40 | 41 | // // new debt = debt + debt*(interest/100); 42 | 43 | // double intPer = interest/(double)100; 44 | // double intMultWithDebt = debt * intPer; 45 | 46 | // double newDebt = debt + intMultWithDebt; 47 | 48 | // Console.WriteLine(Math.Round(newDebt)); -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.Extensions.Logging; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace ASPNETCoreWebAPI.Controllers 9 | { 10 | [ApiController] 11 | [Route("[controller]")] 12 | public class WeatherForecastController : ControllerBase 13 | { 14 | private static readonly string[] Summaries = new[] 15 | { 16 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 17 | }; 18 | 19 | private readonly ILogger _logger; 20 | 21 | public WeatherForecastController(ILogger logger) 22 | { 23 | _logger = logger; 24 | } 25 | 26 | [HttpGet] 27 | public IEnumerable Get() 28 | { 29 | var rng = new Random(); 30 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 31 | { 32 | Date = DateTime.Now.AddDays(index), 33 | TemperatureC = rng.Next(-20, 55), 34 | Summary = Summaries[rng.Next(Summaries.Length)] 35 | }) 36 | .ToArray(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/RoutePlanner2DArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class RoutePlanner 4 | { 5 | public static bool RouteExists(int fromRow, int fromColumn, int toRow, int toColumn, 6 | bool[,] mapMatrix) 7 | { 8 | int currentRow = fromRow; 9 | int currentColumn = fromColumn; 10 | if (!mapMatrix[currentRow, currentColumn]) 11 | return false; 12 | 13 | while (true) 14 | { 15 | if (currentRow + 1 < mapMatrix.Length && mapMatrix[currentRow + 1, currentColumn]) 16 | { 17 | currentRow++; 18 | if (currentRow == toRow && currentColumn == toColumn) 19 | return true; 20 | } 21 | 22 | if (currentColumn + 1 < mapMatrix.Length && mapMatrix[currentRow, currentColumn + 1]) 23 | { 24 | currentColumn++; 25 | if (currentRow == toRow && currentColumn == toColumn) 26 | return true; 27 | } 28 | } 29 | } 30 | 31 | public static void Main2(string[] args) 32 | { 33 | bool[,] mapMatrix = { 34 | {true, false, false}, 35 | {true, true, false}, 36 | {false, true, true} 37 | }; 38 | 39 | Console.WriteLine(RouteExists(0, 0, 2, 2, mapMatrix)); 40 | } 41 | } -------------------------------------------------------------------------------- /LINQ/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/CSharpBasics.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/CSharpBasics.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/CSharpBasics.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /Arrays/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/CSharpBasics.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/CSharpBasics.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/CSharpBasics.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /Strings/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/CSharpBasics.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/CSharpBasics.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/CSharpBasics.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /DataStructures/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/CSharpBasics.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/CSharpBasics.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/CSharpBasics.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /AsyncAwaitDemo/Testing.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using System.Collections; 6 | using System.Collections.ObjectModel; 7 | 8 | namespace AsyncAwaitDemo 9 | { 10 | class Testing 11 | { 12 | static async Task Main() 13 | { 14 | //Task makingCoffeeTask = MakeCoffee(); 15 | //Task makingOmleteTask = MakeOmlete(); 16 | 17 | //await makingOmleteTask; 18 | //await makingCoffeeTask; 19 | string name = "Fahad"; 20 | Console.WriteLine(name.Remove(name.Length - 1)); 21 | 22 | } 23 | 24 | public static void Display(params int[] b) 25 | { 26 | foreach (int i in b) 27 | { 28 | Console.WriteLine("ARRAY IS HAVING:{0}", i); 29 | } 30 | } 31 | 32 | public static async Task MakeCoffee() 33 | { 34 | Console.WriteLine("Started => making the coffee"); 35 | await Task.Delay(4000); 36 | Console.WriteLine("Done => making the coffee"); 37 | } 38 | 39 | public static async Task MakeOmlete() 40 | { 41 | Console.WriteLine("Started => making the omlete"); 42 | await Task.Delay(3000); 43 | Console.WriteLine("Done => making the omlete"); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Fundamentals/CarDemo/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/CSharpBasics.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/CSharpBasics.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/CSharpBasics.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /Interviews/WayFair/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/CSharpBasics.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/CSharpBasics.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/CSharpBasics.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /Problem Solving - Practice/CodeWars/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/CSharpBasics.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/CSharpBasics.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/CSharpBasics.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /DataStructures/Notes.txt: -------------------------------------------------------------------------------- 1 | Stack 2 | -> Push 3 | -> Pop 4 | -> Peek 5 | -> TryPeek 6 | -> TryPop 7 | 8 | Queue 9 | -> Enqueue 10 | -> Dequeue 11 | -> Peek 12 | -> TryPeek 13 | -> TryDequeue 14 | 15 | SortedList 16 | -> It's a KeyValue data structure 17 | -> The keys get sorted as soon as they are inserted 18 | -> There cannot to duplicate keys 19 | -> Values can be null or duplicate 20 | -> It's faster than List 21 | 22 | Dictionary 23 | -> Dictionary stores key-value pairs. 24 | -> Comes under System.Collections.Generic namespace. 25 | -> Implements IDictionary interface. 26 | -> Keys must be unique and cannot be null. 27 | -> Values can be null or duplicate. 28 | -> Values can be accessed by passing associated key in the indexer e.g. myDictionary[key] 29 | -> Elements are stored as KeyValuePair objects. 30 | 31 | Hashtable 32 | -> Hashtable stores key-value pairs. 33 | -> Comes under System.Collection namespace. 34 | -> Implements IDictionary interface. 35 | -> Keys must be unique and cannot be null. 36 | -> Values can be null or duplicate. 37 | -> Values can be accessed by passing associated key in the indexer e.g. myHashtable[key] 38 | -> Elements are stored as DictionaryEntry objects. 39 | 40 | Hashset 41 | -> HashSet is an unordered collection of the unique elements 42 | -> It has linq functions -------------------------------------------------------------------------------- /XUnitTestProjectFizzBuzz/UnitTest1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnitTestingFizzBuzz; 3 | using Xunit; 4 | 5 | namespace XUnitTestProjectFizzBuzz 6 | { 7 | public class UnitTest1 8 | { 9 | [Fact] 10 | public void IsNumberDivisibleBy3() 11 | { 12 | //Green 13 | //Arrange 14 | int number = 33; 15 | //Act 16 | bool actual = Program.IsDivisibleBy3(number); 17 | bool expected = true; 18 | //Assert 19 | Assert.Equal(expected, actual); 20 | 21 | //Red 22 | //Arrange 23 | number = 35; 24 | //Act 25 | actual = Program.IsDivisibleBy3(number); 26 | expected = false; 27 | //Assert 28 | Assert.Equal(expected, actual); 29 | } 30 | 31 | [Fact] 32 | public void IsNumberDivisibleBy5() 33 | { 34 | //Green 35 | //Arrange 36 | int number = 10; 37 | //Act 38 | bool actual = Program.IsDivisibleBy5(number); 39 | bool expected = true; 40 | //Assert 41 | Assert.Equal(expected, actual); 42 | 43 | //Red 44 | //Arrange 45 | number = 77; 46 | //Act 47 | actual = Program.IsDivisibleBy5(number); 48 | expected = false; 49 | //Assert 50 | Assert.Equal(expected, actual); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /NUnitTestProjectFizzBuzz/FizzBuzzTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using UnitTestingFizzBuzz; 3 | 4 | namespace NUnitTestProjectFizzBuzz 5 | { 6 | public class FizzBuzzTest 7 | { 8 | [SetUp] 9 | public void Setup() 10 | { 11 | } 12 | 13 | [Test] 14 | public void IsNumberDivisibleBy3() 15 | { 16 | //Green 17 | //Arrange 18 | int number = 33; 19 | //Act 20 | bool actual = Program.IsDivisibleBy3(number); 21 | bool expected = true; 22 | //Assert 23 | Assert.AreEqual(expected, actual); 24 | 25 | //Red 26 | //Arrange 27 | number = 35; 28 | //Act 29 | actual = Program.IsDivisibleBy3(number); 30 | expected = false; 31 | //Assert 32 | Assert.AreEqual(expected, actual); 33 | } 34 | 35 | [Test] 36 | public void IsNumberDivisibleBy5() 37 | { 38 | //Green 39 | //Arrange 40 | int number = 10; 41 | //Act 42 | bool actual = Program.IsDivisibleBy5(number); 43 | bool expected = true; 44 | //Assert 45 | Assert.AreEqual(expected, actual); 46 | 47 | //Red 48 | //Arrange 49 | number = 77; 50 | //Act 51 | actual = Program.IsDivisibleBy5(number); 52 | expected = false; 53 | //Assert 54 | Assert.AreEqual(expected, actual); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /MSTestProject/FizzBuzzTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using UnitTestingFizzBuzz; 6 | 7 | namespace MSTestProject 8 | { 9 | [TestClass] 10 | public class FizzBuzzTest 11 | { 12 | [TestMethod] 13 | public void IsNumberDivisibleBy3() 14 | { 15 | //Green 16 | //Arrange 17 | int number = 33; 18 | //Act 19 | bool actual = Program.IsDivisibleBy3(number); 20 | bool expected = true; 21 | //Assert 22 | Assert.AreEqual(expected, actual); 23 | 24 | //Red 25 | //Arrange 26 | number = 35; 27 | //Act 28 | actual = Program.IsDivisibleBy3(number); 29 | expected = false; 30 | //Assert 31 | Assert.AreEqual(expected, actual); 32 | } 33 | 34 | [TestMethod] 35 | public void IsNumberDivisibleBy5() 36 | { 37 | //Green 38 | //Arrange 39 | int number = 10; 40 | //Act 41 | bool actual = Program.IsDivisibleBy5(number); 42 | bool expected = true; 43 | //Assert 44 | Assert.AreEqual(expected, actual); 45 | 46 | //Red 47 | //Arrange 48 | number = 77; 49 | //Act 50 | actual = Program.IsDivisibleBy5(number); 51 | expected = false; 52 | //Assert 53 | Assert.AreEqual(expected, actual); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Interviews/Sciata/TestSwab/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class Node 5 | { 6 | public int Value { get; set; } 7 | public Node Left { get; set; } 8 | public Node Right { get; set; } 9 | 10 | public Node(int value, Node left, Node right) 11 | { 12 | Value = value; 13 | Left = left; 14 | Right = right; 15 | } 16 | } 17 | 18 | public class BinarySearchTree 19 | { 20 | public static bool Contains(Node root, int value) 21 | { 22 | Node currentRoot = root; 23 | //while(true) 24 | { 25 | if (currentRoot.Value == value) 26 | return true; 27 | 28 | if (currentRoot.Value < value) 29 | { 30 | if (currentRoot.Right != null) 31 | //currentRoot = currentRoot.Right; 32 | return Contains(currentRoot.Right, value); 33 | else 34 | return false; 35 | } 36 | 37 | if (currentRoot.Value > value) 38 | { 39 | if (currentRoot.Left != null) 40 | //currentRoot = currentRoot.Left; 41 | return Contains(currentRoot.Left, value); 42 | else 43 | return false; 44 | } 45 | } 46 | return false; 47 | } 48 | 49 | public static void Main(string[] args) 50 | { 51 | Node n1 = new Node(1, null, null); 52 | Node n3 = new Node(3, null, null); 53 | Node n2 = new Node(2, n1, n3); 54 | 55 | Console.WriteLine(Contains(n2, 1)); 56 | } 57 | } -------------------------------------------------------------------------------- /UnitTestingDemo/UnitTestingDemo.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestingDemo", "UnitTestingDemo\UnitTestingDemo.csproj", "{C08E9BF1-EFD2-41D8-887B-1836CD6CAE7C}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankTests", "BankTests\BankTests.csproj", "{25EBCDD9-987B-4EE7-B817-8F78583DCD80}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {C08E9BF1-EFD2-41D8-887B-1836CD6CAE7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {C08E9BF1-EFD2-41D8-887B-1836CD6CAE7C}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {C08E9BF1-EFD2-41D8-887B-1836CD6CAE7C}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {C08E9BF1-EFD2-41D8-887B-1836CD6CAE7C}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {25EBCDD9-987B-4EE7-B817-8F78583DCD80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {25EBCDD9-987B-4EE7-B817-8F78583DCD80}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {25EBCDD9-987B-4EE7-B817-8F78583DCD80}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {25EBCDD9-987B-4EE7-B817-8F78583DCD80}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D874AE57-CDF1-4667-92CB-F390C6EC126C} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/TestDomePractice.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestDomePractice", "TestDomePractice.csproj", "{FCCB05CE-44F2-446C-9297-D09D2927165F}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NUnitTestProject", "..\NUnitTestProject\NUnitTestProject.csproj", "{0BEED7FE-4AB6-4A34-87AD-E1565D94FF57}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {FCCB05CE-44F2-446C-9297-D09D2927165F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {FCCB05CE-44F2-446C-9297-D09D2927165F}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {FCCB05CE-44F2-446C-9297-D09D2927165F}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {FCCB05CE-44F2-446C-9297-D09D2927165F}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {0BEED7FE-4AB6-4A34-87AD-E1565D94FF57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {0BEED7FE-4AB6-4A34-87AD-E1565D94FF57}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {0BEED7FE-4AB6-4A34-87AD-E1565D94FF57}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {0BEED7FE-4AB6-4A34-87AD-E1565D94FF57}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {F376E268-281D-4C15-B6E2-A82ECBEAE1F4} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /UnitTestingDemo/UnitTestingDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BankAccountNS 4 | { 5 | /// 6 | /// Bank account demo class. 7 | /// 8 | public class BankAccount 9 | { 10 | private readonly string m_customerName; 11 | private double m_balance; 12 | 13 | private BankAccount() { } 14 | 15 | public BankAccount(string customerName, double balance) 16 | { 17 | m_customerName = customerName; 18 | m_balance = balance; 19 | } 20 | 21 | public string CustomerName 22 | { 23 | get { return m_customerName; } 24 | } 25 | 26 | public double Balance 27 | { 28 | get { return m_balance; } 29 | } 30 | 31 | public void Debit(double amount) 32 | { 33 | if (amount > m_balance) 34 | { 35 | throw new ArgumentOutOfRangeException("amount"); 36 | } 37 | 38 | if (amount < 0) 39 | { 40 | throw new ArgumentOutOfRangeException("amount"); 41 | } 42 | 43 | m_balance -= amount; // intentionally incorrect code 44 | } 45 | 46 | public void Credit(double amount) 47 | { 48 | if (amount < 0) 49 | { 50 | throw new ArgumentOutOfRangeException("amount"); 51 | } 52 | 53 | m_balance += amount; 54 | } 55 | 56 | public static void Main() 57 | { 58 | BankAccount ba = new BankAccount("Mr. Bryan Walton", 11.99); 59 | 60 | ba.Credit(5.77); 61 | ba.Debit(11.22); 62 | Console.WriteLine("Current balance is ${0}", ba.Balance); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Controllers/AuthorController.cs: -------------------------------------------------------------------------------- 1 | using ASPNETCoreWebAPI.Models; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.EntityFrameworkCore; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 10 | 11 | namespace ASPNETCoreWebAPI.Controllers 12 | { 13 | [Route("api/[controller]")] 14 | [ApiController] 15 | public class AuthorController : ControllerBase 16 | { 17 | private readonly BookStoresDBContext _bookStoresDBContext; 18 | 19 | public AuthorController(BookStoresDBContext bookStoresDBContext) 20 | { 21 | _bookStoresDBContext = bookStoresDBContext; 22 | } 23 | 24 | // GET: api/ 25 | [HttpGet] 26 | public async Task> Get() 27 | { 28 | var authors = await _bookStoresDBContext.Authors 29 | .Include(a => a.BookAuthors) 30 | .ToListAsync(); 31 | return authors; 32 | } 33 | 34 | // GET api//5 35 | [HttpGet("{id}")] 36 | public string Get(int id) 37 | { 38 | return "value"; 39 | } 40 | 41 | // POST api/ 42 | [HttpPost] 43 | public void Post([FromBody] string value) 44 | { 45 | } 46 | 47 | // PUT api//5 48 | [HttpPut("{id}")] 49 | public void Put(int id, [FromBody] string value) 50 | { 51 | } 52 | 53 | // DELETE api//5 54 | [HttpDelete("{id}")] 55 | public void Delete(int id) 56 | { 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Fundamentals/CarDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace CSharpBasics 6 | { 7 | class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | //Car car = new Car(); 12 | //car.type = "Sedan"; 13 | 14 | IVehicle tesla = new Car(); 15 | IVehicle JBL = new Crane(); 16 | tesla.Honk(); 17 | JBL.Honk(); 18 | 19 | Console.WriteLine((int)CarTypes.HatchBack); 20 | 21 | } 22 | /* 23 | Properties have get and set accessors, which provide more control on how values are set or returned. 24 | C# allows you either to create a private field for storing the property value or 25 | use auto-implemented properties that create this field automatically behind the scenes 26 | and provide the basic logic for the property procedures. 27 | */ 28 | 29 | /* 30 | Difference between Structs and Classes: 31 | Structs are value type whereas Classes are reference type. 32 | Structs are stored on the stack whereas Classes are stored on the heap. 33 | ... When you copy struct into another struct, a new copy of that struct gets created modified of one struct won't affect the value of the other struct. 34 | */ 35 | 36 | abstract class Shape 37 | { 38 | public abstract int GetArea(); 39 | 40 | public string GetName() 41 | { 42 | return "Fahad"; 43 | } 44 | } 45 | 46 | public struct BaseStruct 47 | { 48 | 49 | } 50 | 51 | struct Product // :BaseStruct you can't inherit in structs 52 | { 53 | //public string productName; 54 | public int MyProperty { get; set; } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Notes.txt: -------------------------------------------------------------------------------- 1 | ------ Data Structures ---- 2 | 3 | Stack 4 | -> Push 5 | -> Pop 6 | -> Peek 7 | -> TryPeek 8 | -> TryPop 9 | 10 | Queue 11 | -> Enqueue 12 | -> Dequeue 13 | -> Peek 14 | -> TryPeek 15 | -> TryDequeue 16 | 17 | SortedList 18 | -> It's a KeyValue data structure 19 | -> The keys get sorted as soon as they are inserted 20 | -> There cannot to duplicate keys 21 | -> Values can be null or duplicate 22 | -> It's faster than List 23 | 24 | Dictionary 25 | -> Dictionary stores key-value pairs. 26 | -> Comes under System.Collections.Generic namespace. 27 | -> Implements IDictionary interface. 28 | -> Keys must be unique and cannot be null. 29 | -> Values can be null or duplicate. 30 | -> Values can be accessed by passing associated key in the indexer e.g. myDictionary[key] 31 | -> Elements are stored as KeyValuePair objects. 32 | 33 | Hashtable 34 | -> Hashtable stores key-value pairs. 35 | -> Comes under System.Collection namespace. 36 | -> Implements IDictionary interface. 37 | -> Keys must be unique and cannot be null. 38 | -> Values can be null or duplicate. 39 | -> Values can be accessed by passing associated key in the indexer e.g. myHashtable[key] 40 | -> Elements are stored as DictionaryEntry objects. 41 | 42 | Tuples 43 | -> (double, int) t1 = (4.5, 3); 44 | -> (double Sum, int Count) t2 = (4.5, 3); 45 | -> var t = (Sum: 4.5, Count: 3); 46 | -> t3 = t2; 47 | 48 | ------ Numbers ---- 49 | 50 | The Decimal, Double, and Float variable types are different in the way that they store the values. 51 | Precision is the main difference where float is a single precision (32 bit) floating point data type, 52 | double is a double precision (64 bit) floating point data type 53 | and decimal is a 128-bit floating point data type. 54 | -------------------------------------------------------------------------------- /Interviews/WayFair/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | /* 6 | You are building an educational website and want to create a simple calculator for students to use. The calculator will only allow addition and subtraction of non-negative integers. 7 | 8 | Given an expression string using the "+" and "-" operators like "5+16-2", write a function to find the total. 9 | 10 | Sample input/output: 11 | calculate("6+9-12") => 3 12 | calculate("1+2-3+4-5+6-7") => -2 13 | calculate("100+200+300") => 600 14 | calculate("1-2-3-0") => -4 15 | calculate("255") => 255 16 | 17 | n: length of the input string 18 | 19 | */ 20 | 21 | class Solution 22 | { 23 | static void Main(String[] args) 24 | { 25 | // 10-1+2+3 26 | // "10","1+2+3" 27 | //10 + "-1" +"2" + "3" 28 | 29 | //string expression1 = "6+9-12"; // = 3 30 | //string expression2 = "1+2-3+4-5+6-7"; // = -2 31 | //"1+2", "3+4", "5+6", "7" 32 | // ("1" , "2") ,("-3","4"), ("-5", "6") ("-7") 33 | // 3, 1 34 | //string expression3 = "100+200+300"; // = 600 35 | string expression4 = "1-2-3-0"; // = -4 36 | //string expression5 = "255"; // = 255 37 | 38 | Console.WriteLine(Calculate(expression4)); 39 | } 40 | 41 | public static int Calculate(string expression) 42 | { 43 | int result = 0; 44 | string[] minusExpression = expression.Split('-'); 45 | 46 | // minusExpression = "1+2", "3+4", "5+6", "7" 47 | for (int i = 0; i < minusExpression.Length; i++) 48 | { 49 | string[] sumExpression = minusExpression[i].Split('+'); 50 | 51 | //sumExpression = "1" , "2" 52 | //sumExpression = "-3", 5 53 | 54 | for (int j = 0; j < sumExpression.Length; j++) 55 | { 56 | if (i > 0 && j == 0) 57 | { 58 | result -= Convert.ToInt32(sumExpression[j]); 59 | } 60 | else 61 | result += Convert.ToInt32(sumExpression[j]); 62 | } 63 | } 64 | return result; 65 | } 66 | } -------------------------------------------------------------------------------- /DelegatesDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace DelegatesDemo 6 | { 7 | class Program 8 | { 9 | public delegate int Calculate(int x, int y); 10 | 11 | static void Main(string[] args) 12 | { 13 | //declaring delegates on top of class 14 | Calculate add = Add; 15 | Calculate multiply = (x, y) => x * y; 16 | //Calculate divide = (x, y) => x / y; ; 17 | //Calculate substract = (x, y) => x - y; 18 | 19 | Console.WriteLine(add(10,10)); 20 | //Console.WriteLine(multiply(10,10)); 21 | //Console.WriteLine(divide(10, 10)); 22 | //Console.WriteLine(substract(10, 10)); 23 | 24 | //declaring the delegate function at runtime, by using Func<> 25 | Func add = (x,y) => x + y; 26 | Func substract = (x,y) => x - y; 27 | Func multiply = (x,y) => x * y; 28 | Func divide = (x,y) => x / y; 29 | 30 | //Console.WriteLine(add(10, 13)); 31 | //Console.WriteLine(substract(10, 13)); 32 | //Console.WriteLine(multiply(10, 13)); 33 | //Console.WriteLine(divide(10, 13)); 34 | 35 | //you can also use actions if the functions that you are calling does not have return type 36 | //Action add = (x, y) => { Console.WriteLine(x + y); }; 37 | //Action substract = (x, y) => { Console.WriteLine(x - y); }; 38 | //Action multiply = (x, y) => { Console.WriteLine(x * y); }; 39 | //Action divide = (x, y) => { Console.WriteLine(x / y); }; 40 | 41 | //add(10,20);multiply(10, 24);substract(10, 12);divide(11, 11); 42 | 43 | //predicate 44 | Predicate predicate = (number) => { return number > 20 ? true : false; }; 45 | List numbers = new List { 10, 20, 5 }; 46 | Console.WriteLine(String.Join(" ",numbers.FindAll(predicate))); 47 | } 48 | 49 | public static int Add(int x, int y) 50 | { 51 | return x + y; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Problem Solving - Practice/TestDome/SortedSearch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace TestDomePractice 7 | { 8 | public class SortedSearch 9 | { 10 | public static int CountNumbers(int[] sortedArray, int lessThan) 11 | { 12 | //1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25 13 | int min = 0; 14 | int max = sortedArray.Length - 1; 15 | int mid = 0; 16 | while(min <= max) 17 | { 18 | mid = (min + max) / 2; 19 | if(sortedArray[mid] == lessThan) 20 | { 21 | return mid; 22 | } 23 | else if(sortedArray[mid] > lessThan) 24 | { 25 | max = mid - 1; 26 | } 27 | else if(sortedArray[mid] < lessThan) 28 | { 29 | min = mid + 1; 30 | } 31 | } 32 | return mid; 33 | } 34 | 35 | public static int CountNumbersRecursive(int[] sortedArray, int lessThan, int min, int max, int mid) 36 | { 37 | if(min > max) 38 | { 39 | return mid+1; 40 | } 41 | else 42 | { 43 | if(sortedArray[mid] == lessThan) 44 | { 45 | return mid; 46 | } 47 | else if(sortedArray[mid] > lessThan) 48 | { 49 | return CountNumbersRecursive(sortedArray, lessThan, min, mid - 1, (min + mid - 1) / 2); 50 | } 51 | else if(sortedArray[mid] < lessThan) 52 | { 53 | return CountNumbersRecursive(sortedArray, lessThan, mid + 1, max, (mid + 1 + max) / 2); 54 | } 55 | } 56 | return mid+1; 57 | } 58 | 59 | public static void Main(string[] args) 60 | { 61 | int[] sortedArray = new int[] { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25 }; 62 | Console.WriteLine(SortedSearch.CountNumbersRecursive(sortedArray, 7, 0 , sortedArray.Length - 1, (sortedArray.Length - 1)/2)); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using ASPNETCoreWebAPI.Models; 2 | using Microsoft.AspNetCore.Builder; 3 | using Microsoft.AspNetCore.Hosting; 4 | using Microsoft.AspNetCore.HttpsPolicy; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.Extensions.Logging; 10 | using Microsoft.OpenApi.Models; 11 | using System; 12 | using System.Collections.Generic; 13 | using System.Linq; 14 | using System.Threading.Tasks; 15 | 16 | namespace ASPNETCoreWebAPI 17 | { 18 | public class Startup 19 | { 20 | public Startup(IConfiguration configuration) 21 | { 22 | Configuration = configuration; 23 | } 24 | 25 | public IConfiguration Configuration { get; } 26 | 27 | // This method gets called by the runtime. Use this method to add services to the container. 28 | public void ConfigureServices(IServiceCollection services) 29 | { 30 | 31 | services.AddControllers(); 32 | services.AddSwaggerGen(c => 33 | { 34 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "ASPNETCoreWebAPI", Version = "v1" }); 35 | }); 36 | services.AddDbContext(); 37 | services.AddControllersWithViews() 38 | .AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); 39 | } 40 | 41 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 42 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 43 | { 44 | if (env.IsDevelopment()) 45 | { 46 | app.UseDeveloperExceptionPage(); 47 | app.UseSwagger(); 48 | app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "ASPNETCoreWebAPI v1")); 49 | } 50 | 51 | app.UseHttpsRedirection(); 52 | 53 | app.UseRouting(); 54 | 55 | app.UseAuthorization(); 56 | 57 | app.UseEndpoints(endpoints => 58 | { 59 | endpoints.MapControllers(); 60 | }); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /CSharpAlgorithms/BinarySearch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace CSharpAlgorithms 5 | { 6 | class BinarySearch 7 | { 8 | static void Main2(string[] args) 9 | { 10 | //implemeting binary search 11 | int[] sortedArray = new int[] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150 }; 12 | int position = BinarySearchIterative(sortedArray, 70); 13 | position = BinarySeachRecursive(sortedArray, 150, 0, sortedArray.Length - 1); 14 | 15 | Console.Write(position); 16 | } 17 | 18 | public static int BinarySearchIterative(int[] sortedArray, int searchNumber) 19 | { 20 | //10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110 21 | int min = 0; 22 | int max = sortedArray.Length - 1; 23 | 24 | while(min <= max) 25 | { 26 | int mid = (min + max) / 2; 27 | if (sortedArray[mid] == searchNumber) 28 | { 29 | return mid; 30 | } 31 | else if (sortedArray[mid] > searchNumber) 32 | { 33 | max = mid - 1; 34 | } 35 | else if (sortedArray[mid] < searchNumber) 36 | { 37 | min = mid + 1; 38 | } 39 | } 40 | return -1; 41 | } 42 | 43 | public static int BinarySeachRecursive(int[] sortedArray, int searchNumber, int min, int max) 44 | { 45 | if(min > max) 46 | { 47 | return -1; 48 | } 49 | else 50 | { 51 | int mid = (min + max) / 2; 52 | if(sortedArray[mid] == searchNumber) 53 | { 54 | return mid; 55 | } 56 | else if(sortedArray[mid] > searchNumber) 57 | { 58 | return BinarySeachRecursive(sortedArray, searchNumber, min, mid - 1); 59 | } 60 | else if (sortedArray[mid] < searchNumber) 61 | { 62 | return BinarySeachRecursive(sortedArray, searchNumber, mid + 1, max); 63 | } 64 | } 65 | return -1; 66 | } 67 | 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /UnitTestingFizzBuzz/UnitTestingFizzBuzz.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestingFizzBuzz", "UnitTestingFizzBuzz.csproj", "{2173A871-FC0F-44FB-9D11-FB9F4A8F59B9}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSTestProject", "..\MSTestProject\MSTestProject.csproj", "{5E782054-3CC4-4C08-BC43-3AB9D785174F}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NUnitTestProjectFizzBuzz", "..\NUnitTestProjectFizzBuzz\NUnitTestProjectFizzBuzz.csproj", "{808E2770-DDB7-4954-BC22-E0FA265F9067}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTestProjectFizzBuzz", "..\XUnitTestProjectFizzBuzz\XUnitTestProjectFizzBuzz.csproj", "{A8F8CF9B-B9F6-4B6A-8FC2-753F7F7721C5}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {2173A871-FC0F-44FB-9D11-FB9F4A8F59B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {2173A871-FC0F-44FB-9D11-FB9F4A8F59B9}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {2173A871-FC0F-44FB-9D11-FB9F4A8F59B9}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {2173A871-FC0F-44FB-9D11-FB9F4A8F59B9}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {5E782054-3CC4-4C08-BC43-3AB9D785174F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {5E782054-3CC4-4C08-BC43-3AB9D785174F}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {5E782054-3CC4-4C08-BC43-3AB9D785174F}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {5E782054-3CC4-4C08-BC43-3AB9D785174F}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {808E2770-DDB7-4954-BC22-E0FA265F9067}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {808E2770-DDB7-4954-BC22-E0FA265F9067}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {808E2770-DDB7-4954-BC22-E0FA265F9067}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {808E2770-DDB7-4954-BC22-E0FA265F9067}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {A8F8CF9B-B9F6-4B6A-8FC2-753F7F7721C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {A8F8CF9B-B9F6-4B6A-8FC2-753F7F7721C5}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {A8F8CF9B-B9F6-4B6A-8FC2-753F7F7721C5}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {A8F8CF9B-B9F6-4B6A-8FC2-753F7F7721C5}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {5938C37D-31B9-4F2A-9EEB-77DFA371EA17} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Controllers/PeopleController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace ASPNETCoreWebAPI.Controllers 8 | { 9 | [ApiController] 10 | [Route("people")] 11 | public class PeopleController : ControllerBase 12 | { 13 | List people = new List(); 14 | 15 | [HttpGet] 16 | public async Task> Get() 17 | { 18 | return await Task.Run(() => LoadPeople()); 19 | } 20 | 21 | [HttpPost("CreatePerson")] 22 | public async Task> Post(Person person) 23 | { 24 | return await Task.Run(() => CreatedAtAction($"getperson/{1}", new Person())); 25 | } 26 | 27 | [HttpPut("UpdatePerson")] 28 | public async Task> Update(Person person) 29 | { 30 | return await Task.Run(() => CreatedAtAction($"getperson/{1}", new Person())); 31 | } 32 | 33 | [HttpGet("getperson/{id}")] 34 | public async Task> GetPerson(int id) 35 | { 36 | return await Task.FromResult(LoadPeople().Where(p => p.Id == id).FirstOrDefault()); 37 | } 38 | 39 | [HttpDelete("{id}")] 40 | public ActionResult> DeletePerson(int id) 41 | { 42 | LoadPeople(); 43 | people.Remove(people.Where(p => p.Id == id).FirstOrDefault()); 44 | return people; 45 | } 46 | 47 | private List LoadPeople() 48 | { 49 | people.Add(new Person() 50 | { 51 | Id = 1, 52 | FirstName = "Fahad", 53 | LastName = "Mullaji", 54 | DateOfBirth = Convert.ToDateTime("12/08/1988"), 55 | Salary = 90000 56 | }); 57 | people.Add(new Person() 58 | { 59 | Id = 2, 60 | FirstName = "Monica", 61 | LastName = "Mullaji", 62 | DateOfBirth = Convert.ToDateTime("04/12/1990"), 63 | Salary = 90000 64 | }); 65 | people.Add(new Person() 66 | { 67 | Id = 3, 68 | FirstName = "Erin", 69 | LastName = "Carr", 70 | DateOfBirth = Convert.ToDateTime("12/08/1988"), 71 | Salary = 45000 72 | }); 73 | people.Add(new Person() 74 | { 75 | Id = 4, 76 | FirstName = "Joe", 77 | LastName = "Fogiato", 78 | DateOfBirth = Convert.ToDateTime("12/08/1988"), 79 | Salary = 90000 80 | }); 81 | 82 | return people; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Problem Solving - Practice/CodeWars/PaginationHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace CSharpBasics 6 | { 7 | public class PagnationHelper 8 | { 9 | // TODO: Complete this class 10 | private IList Items; 11 | private int ItemsPerPage; 12 | /// 13 | /// Constructor, takes in a list of items and the number of items that fit within a single page 14 | /// 15 | /// A list of items 16 | /// The number of items that fit within a single page 17 | public PagnationHelper(IList collection, int itemsPerPage) 18 | { 19 | Items = collection; 20 | ItemsPerPage = itemsPerPage; 21 | } 22 | 23 | /// 24 | /// The number of items within the collection 25 | /// 26 | public int ItemCount 27 | { 28 | get 29 | { 30 | return Items.Count; 31 | } 32 | } 33 | 34 | /// 35 | /// The number of pages 36 | /// 37 | public int PageCount 38 | { 39 | get 40 | { 41 | if (Items.Count % ItemsPerPage == 0) 42 | return Items.Count / ItemsPerPage; 43 | else 44 | return (Items.Count / ItemsPerPage) + 1; 45 | } 46 | } 47 | 48 | /// 49 | /// Returns the number of items in the page at the given page index 50 | /// 51 | /// The zero-based page index to get the number of items for 52 | /// The number of items on the specified page or -1 for pageIndex values that are out of range 53 | public int PageItemCount(int pageIndex) 54 | { 55 | if (pageIndex < 0) 56 | return -1; 57 | else 58 | { 59 | int count = Items.Skip(ItemsPerPage * pageIndex).Take(ItemsPerPage).Count(); 60 | if (count > 0) 61 | return count; 62 | else 63 | return -1; 64 | } 65 | } 66 | 67 | /// 68 | /// Returns the page index of the page containing the item at the given item index. 69 | /// 70 | /// The zero-based index of the item to get the pageIndex for 71 | /// The zero-based page index of the page containing the item at the given item index or -1 if the item index is out of range 72 | public int PageIndex(int itemIndex) 73 | { 74 | if (itemIndex <= Items.Count() - 1 && itemIndex > -1) 75 | return itemIndex / ItemsPerPage; 76 | else 77 | return -1; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /TuplesDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace TuplesDemo 6 | { 7 | class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | //creating list of tuples 12 | //List> listTuples = new List>(); 13 | 14 | //different ways to create tuples 15 | //(double, int) firstTuple = (11.1, 4); 16 | //listTuples.Add(firstTuple.ToTuple()); 17 | 18 | //var secondTuple = (5.5, 4); 19 | //listTuples.Add(secondTuple.ToTuple()); 20 | 21 | //listTuples.Add(Tuple.Create(99.0, 12)); 22 | 23 | //Console.WriteLine($"{listTuples[1].Item1} {listTuples[1].Item2}"); 24 | 25 | //a way to name your tuple items 26 | //var vowels = (firstLetter : "a", "e", "i", "o", "u"); 27 | //Console.WriteLine(vowels.firstLetter); 28 | 29 | //var maxMin = FindMaxMin(new int[] { 1, 2, 3, 4, 5, 6, 7, }); 30 | //Console.WriteLine(maxMin); 31 | 32 | //another way to name tuple items 33 | //var sum = 99; 34 | //var count = 5; 35 | //var tuple = (sum, count); 36 | //Console.WriteLine(tuple.sum); 37 | 38 | //assigment operators for tuples 39 | //var t1 = (11, 11); 40 | //var t2 = (0, 0.5); 41 | //t2 = t1; 42 | //Console.WriteLine(t2); 43 | 44 | //assgning the property names 45 | //var nameAge = ("Fahad", 32); 46 | //(string name, int age) = nameAge; 47 | //(string name, int age) temp = nameAge; 48 | //Console.WriteLine($"name is {temp.name} and age is {temp.age}"); 49 | 50 | //another way to assign property names 51 | //var nameAge = ("Fahad", 32); 52 | //var (name, age) = nameAge; 53 | //Console.WriteLine($"name is {name} and age is {age}"); 54 | 55 | //assigning a tuple to bunch of variables 56 | //var destination = string.Empty; 57 | //var distance = 0.0; 58 | //var t = ("post office", 3.6); 59 | //(destination, distance) = t; 60 | //Console.WriteLine($"Distance to {destination} is {distance} kilometers."); 61 | 62 | //tuples equality 63 | //(byte a, byte b) t1 = (10, 1); 64 | //(int x, int y) t2 = (11, 1); 65 | //if (t1 == t2) Console.WriteLine(true); 66 | //else Console.WriteLine(false); 67 | 68 | //in this example you can see that Tuples does not consider the field names 69 | //var t1 = (A: 5, B: 10); 70 | //var t2 = (B: 5, A: 10); 71 | //Console.WriteLine(t1 == t2); // output: True 72 | //Console.WriteLine(t1 != t2); // output: False 73 | } 74 | 75 | public static (int, int) FindMaxMin(int[] numbers) 76 | { 77 | return (numbers.Max(), numbers.Min()); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Interviews/SIG/SIG/Program.cs: -------------------------------------------------------------------------------- 1 | // See https://aka.ms/new-console-template for more information 2 | Console.WriteLine(); 3 | 4 | int[] solution(int[] balances, string[] requests) { 5 | 6 | long dayInSeconds = 86400; 7 | Dictionary> accountIndexWithdrawalTimestamp = new Dictionary>(); 8 | 9 | for(int i = 0; i < requests.Length; i++) 10 | { 11 | string[] splitRequest = requests[i].Split(' '); 12 | 13 | if(splitRequest.Length == 4) 14 | { 15 | string operation = splitRequest[0]; 16 | long timestamp = Convert.ToInt64(splitRequest[1]); 17 | int accountIndex = Convert.ToInt32(splitRequest[2])-1; 18 | int amount = Convert.ToInt32(splitRequest[3]); 19 | 20 | // if the account id is invalid 21 | if((accountIndex+1) > balances.Length) 22 | { 23 | return GetInvalidRequest(i); 24 | } 25 | 26 | // apply cashback 27 | foreach (var accountIndexWithdrawalTimestampEntry in accountIndexWithdrawalTimestamp) 28 | { 29 | Dictionary> cashbackEntriesToBeRemoved = new Dictionary>(); 30 | 31 | // applying cashback from the history 32 | foreach(var cashbackEntryToBeApplied in accountIndexWithdrawalTimestampEntry.Value) 33 | { 34 | if(timestamp - cashbackEntryToBeApplied.Item1 <= dayInSeconds) 35 | { 36 | int accountIndexOfCashBackToBeApplied = accountIndexWithdrawalTimestampEntry.Key; 37 | 38 | int cashbackAmount = (int)Math.Floor(cashbackEntryToBeApplied.Item2*(2/(decimal)100)); 39 | balances[accountIndexOfCashBackToBeApplied] += cashbackAmount; 40 | 41 | if(!cashbackEntriesToBeRemoved.ContainsKey(accountIndexOfCashBackToBeApplied)) 42 | { 43 | cashbackEntriesToBeRemoved.Add(accountIndexOfCashBackToBeApplied,new List<(long,int)>() { cashbackEntryToBeApplied }); 44 | } 45 | else 46 | { 47 | cashbackEntriesToBeRemoved[accountIndexOfCashBackToBeApplied].Add(cashbackEntryToBeApplied); 48 | } 49 | } 50 | } 51 | 52 | // removing cashback entries from history 53 | foreach(var cashBackEntryToBeRemoved in cashbackEntriesToBeRemoved) 54 | { 55 | foreach(var item in cashBackEntryToBeRemoved.Value) 56 | { 57 | accountIndexWithdrawalTimestamp[cashBackEntryToBeRemoved.Key].Remove(item); 58 | } 59 | } 60 | } 61 | 62 | // if the transaction is withdraw 63 | if(operation == "withdraw") 64 | { 65 | // if the withdrawal amount is greater than balance 66 | if(balances[accountIndex] - amount < 0) 67 | { 68 | return GetInvalidRequest(i); 69 | } 70 | else 71 | { 72 | balances[accountIndex] -= amount; 73 | if(!accountIndexWithdrawalTimestamp.ContainsKey(accountIndex)) 74 | { 75 | accountIndexWithdrawalTimestamp.Add(accountIndex, new List<(long, int)>() {(timestamp, amount)}); 76 | } 77 | else 78 | { 79 | accountIndexWithdrawalTimestamp[accountIndex].Add((timestamp,amount)); 80 | } 81 | } 82 | } 83 | 84 | // if the transaction is deposit 85 | if(operation == "deposit") 86 | { 87 | balances[accountIndex] += amount; 88 | } 89 | } 90 | } 91 | return balances; 92 | } 93 | 94 | int[] GetInvalidRequest(int index) 95 | { 96 | List result = new List(); 97 | 98 | index++; 99 | index = index*(-1); 100 | result.Add(index); 101 | 102 | return result.ToArray(); 103 | } -------------------------------------------------------------------------------- /LINQ/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace CSharpBasics 6 | { 7 | class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | int[] intArray = { 1, 2, 3, 4, 5, 5, 4, 3 }; 12 | int[] intArray2 = { 1, 1, 1, 1, 1, 1, 1, 1 }; 13 | string[] strArray = { "Chiplun", "Chiplun", "Hyderabad", "Topeka", "Pune", "Pune" }; 14 | 15 | Student[] students = { new Student() { StudentId = 1, Score = 10, Name = "Fahad"} , 16 | new Student() { StudentId = 2, Score = 10, Name = "Tanvi"} , 17 | new Student() { StudentId = 3, Score = 10, Name = "Mark"} , 18 | new Student() { StudentId = 4, Score = 20, Name = "Monica"}, 19 | new Student() { StudentId = 5, Score = 20, Name = "Joe"}}; 20 | 21 | Parent[] parents = { new Parent() { StudentId = 1, FirstName = "Rehana" , LastName = "Mullaji"} , 22 | new Parent() { StudentId = 1,FirstName = "Adam" , LastName = "Mullaji"} , 23 | new Parent() { StudentId = 4, FirstName = "Ken" , LastName = "Lord"} , 24 | new Parent() { StudentId = 4, FirstName = "Denise" , LastName = "Lord"}}; 25 | 26 | 27 | //Using group by on string array and sorting it by descending order 28 | // var groupedStringArray = strArray.GroupBy(s => s) 29 | // .OrderByDescending(item => item.Count()); 30 | 31 | // foreach(var item in groupedStringArray) 32 | // { 33 | // Console.WriteLine(item.Key + " : " + item.Count()); 34 | // } 35 | 36 | // Grouping in custom data types 37 | // var groupedStudents = students.GroupBy(s => s.Score).ToList(); 38 | 39 | // foreach(var items in groupedStudents) 40 | // { 41 | // Console.WriteLine(items.Key); 42 | // foreach(var item in items) 43 | // { 44 | // Console.WriteLine(item.Name + "-" + item.Score); 45 | // } 46 | // } 47 | 48 | // Grouping by numbers 49 | // var groupedData = intArray2.GroupBy(number => number).ToList(); 50 | 51 | // foreach(var item in groupedData) 52 | // { 53 | // Console.WriteLine(item.Key + " " + item.Count()); 54 | // } 55 | 56 | //first and last just returns first or last item 57 | //but single throws exception of it finds duplicate value 58 | 59 | // var something = intArray.First(); 60 | // something = intArray.Last(); 61 | 62 | // Console.WriteLine(something); 63 | 64 | // var something = from number in intArray 65 | // from city in strArray 66 | // select new { number, city }; 67 | 68 | // var studentParents = students.Join(parents, 69 | // s => s.StudentId, 70 | // p => p.StudentId, 71 | // (s,p) => new 72 | // { 73 | // Student = s, 74 | // Parent = p 75 | // }); 76 | 77 | // foreach (var item in studentParents) 78 | // Console.WriteLine(item.Student.Name + ": " + item.Parent.FirstName + " + " + item.Parent.LastName); 79 | 80 | // var listCities = (from city in strArray 81 | // where city.StartsWith('P') 82 | // orderby city.Length descending 83 | // select city).ToList(); 84 | 85 | //var listCities = strArray.Where(s => s.StartsWith('P')) 86 | // .OrderByDescending(s => s.Length) 87 | // .Select(s => s); 88 | 89 | // listCities.ForEach(s => Console.WriteLine(s)); 90 | 91 | //var numbers = from number in intArray 92 | // where number > 2 93 | // orderby number descending 94 | // select number; 95 | 96 | //var numbers = intArray.Where(number => number > 2) 97 | // .OrderByDescending(number => number) 98 | // .Select(number => number); 99 | 100 | //var stds = from student in students 101 | // where student.Score > 10 102 | // orderby student.Name descending 103 | // select new { student.Name }; 104 | 105 | //var stds = students.Where(s => s.Score > 10) 106 | // .OrderByDescending(s => s.Name) 107 | // .Select(s => s.Name); 108 | 109 | } 110 | 111 | class Student 112 | { 113 | public int StudentId { get; set; } 114 | public string Name { get; set; } 115 | public int Score { get; set; } 116 | } 117 | 118 | class Parent 119 | { 120 | public int ParentId { get; set; } 121 | public int StudentId { get; set; } 122 | public string FirstName { get; set; } 123 | public string LastName { get; set; } 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Strings/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace CSharpBasics 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | 11 | string str1 = "123456789"; 12 | char[] temp = new char[8]; 13 | 14 | str1.CopyTo(0, temp, 2, str1.Length - 5); 15 | Console.WriteLine(temp); 16 | 17 | //NOTES 18 | 19 | //Trim - ****************** 20 | // this function trims the whitespaces from the start and end 21 | // you can also use TrimEnd and TrimStart to just trim start or end 22 | 23 | //string str1 = " Fahad Mullaji "; 24 | //Console.WriteLine(str1); 25 | 26 | //ToCharArray - ****************** 27 | // this function returns the string in char array 28 | // and you can also get part of char arrya 29 | //by passing start index and the length 30 | 31 | //string str1 = "Fahad Mullaji"; 32 | //char[] arrChar = str1.ToCharArray(1,2); 33 | 34 | //foreach (var item in arrChar) 35 | //Console.Write(item); 36 | 37 | //Substring - ****************** 38 | // this function returns sub string from the start index 39 | // which has been passed in the method 40 | // you can also pass the length of the string that you want back 41 | 42 | //string str1 = "Fahad Mullaji"; 43 | //Console.WriteLine(str1.Substring(2,2)); 44 | 45 | 46 | //StartsWith - ****************** 47 | // this function returns True if the 1st char of the string matches 48 | // the char which has been passed 49 | // else it returns False 50 | 51 | //string str1 = "Fahad Mullaji"; 52 | //Console.WriteLine(str1.StartsWith('<')); 53 | 54 | 55 | //Split - ****************** 56 | // this function is used to split the string in array of strings 57 | // based on the char which has been passed 58 | 59 | //string str1 = "Fahad Mullaji"; 60 | //string[] splitValue = str1.Split(' '); 61 | //Console.WriteLine(splitValue[1]); 62 | 63 | //Replace - ****************** 64 | // this function replaces the char (1st paramter) in the string 65 | // with the char (2nd parameter) 66 | 67 | //string str1 = "Fahad Mullaji"; 68 | //Console.WriteLine(str1.Replace('F', 'M')); 69 | 70 | //Remove - ****************** 71 | // this function removes all the characters from the index which has been passed 72 | // the 2nd paramter takes the length/count of characters to be removed 73 | // and if the passed index is out of range then an exception is thrown 74 | 75 | //string str1 = "Fahad Mullaji"; 76 | //Console.WriteLine(str1.Remove(15,2)); 77 | 78 | //LastIndexOf - ****************** 79 | // this function returns the last occurence position of the char passed 80 | // if the char is not found then it returns -1 81 | 82 | //string str1 = "Fahad Mullaji"; 83 | //Console.WriteLine(str1.LastIndexOf("x")); 84 | 85 | //Insert - ****************** 86 | // this function takes index and inserts a string value at that position 87 | 88 | //string str1 = "Mullaji"; 89 | //Console.WriteLine(str1.Insert(4, "Fahad")); 90 | 91 | //ToLower & ToUpper- ****************** 92 | // ToLower => Converts String into lower case based on rules of the current culture 93 | // ToUpper => Converts String into Upper case based on rules of the current culture 94 | 95 | //string str1 = "Fahad Mullaji"; 96 | //Console.WriteLine(str1.ToLower()); 97 | 98 | //IndexOf - ****************** 99 | // this function returns first index position of the char passed 100 | // if the char is not found then it returns -1 101 | 102 | //string str1 = "Fahad Mullaji"; 103 | //Console.WriteLine(str1.IndexOf('M')); 104 | 105 | 106 | //GetType ****************** 107 | // this returns the type name with the namespace 108 | // index 109 | 110 | //string str1 = "Fahad Mullaji"; 111 | //Console.WriteLine(str1.GetType()); 112 | 113 | //Equals ****************** 114 | // this function returns True when the string is exactly the same 115 | // this is case sensitive 116 | 117 | //string str1 = "Fahad Mullaji"; 118 | //string str2 = "fahad mullaj"; 119 | //Console.WriteLine(str1.Equals(str2)); 120 | 121 | 122 | //EndsWith ****************** 123 | // this function returns True when the last char of the string 124 | // matches the char value passed in the function 125 | // otherwise it returns False 126 | 127 | //string str1 = "Fahad Mullaji"; 128 | //string str2 = "Fahad"; 129 | //Console.WriteLine(str1.EndsWith('j')); 130 | 131 | //Contains ****************** 132 | // this function checks if the string1 contains string2 133 | // it returns True when string2 is part string1 134 | // otherwise it returns False 135 | 136 | //string str1 = "Fahad Mullaji"; 137 | //string str2 = "Fahad"; 138 | //Console.WriteLine(str2.Contains(str1)); 139 | 140 | 141 | //CompareTo - int ****************** 142 | //when 2 integers are same then it returns - 0 143 | //when number1 is greater than number2 then it returns 1 144 | //when number1 is less than number2 then it returns -1 145 | 146 | //int number1 = 20; 147 | //int number2 = 10; 148 | //Console.WriteLine(number1.CompareTo(number2)); 149 | 150 | 151 | //CompareTo - string ****************** 152 | //this is used to compare 2 objects like int and string 153 | //when 2 strings are excatly the same then this returns 0 154 | //when 2 strings are same but in different cases then it returns 1 155 | //when 2 strings are of different then it return -1 156 | //when the string that we comparing is smaller then the main string 157 | //then it return 1 158 | 159 | //string name1 = "Fahad Mullaji"; 160 | //string name2 = "fahad mulla"; 161 | //Console.WriteLine(name1.CompareTo(name2)); 162 | 163 | //Clone ****************** 164 | //this is used for making clone of the string 165 | 166 | //string cloneName = (string)name.Clone(); 167 | //Console.WriteLine(name1.CompareTo(name2)); 168 | } 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | /src/Server/Properties/ServiceDependencies/blazingchatserver - Web Deploy 352 | /src/Notes.txt 353 | /src/WebAPI/Properties/ServiceDependencies/blazingchatwebapi - Web Deploy/profile.arm.json 354 | -------------------------------------------------------------------------------- /AsyncAwaitDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace AsyncBreakfast 7 | { 8 | class Program 9 | { 10 | static async Task Main2(string[] args) 11 | { 12 | Console.WriteLine("SYNCHRONOUS METHOD CALLS"); 13 | Coffee cup = new Coffee(); 14 | Egg eggs = new Egg(); 15 | Bacon bacon = new Bacon(); 16 | Toast toast = new Toast(); 17 | Juice oj = new Juice(); 18 | //cup = PourCoffee(); 19 | //Console.WriteLine("coffee is ready"); 20 | 21 | //eggs = FryEggs(2); 22 | //Console.WriteLine("eggs are ready"); 23 | 24 | //bacon = FryBacon(3); 25 | //Console.WriteLine("bacon is ready"); 26 | 27 | //toast = ToastBread(2); 28 | //ApplyButter(toast); 29 | //ApplyJam(toast); 30 | //Console.WriteLine("toast is ready"); 31 | 32 | //oj = PourOJ(); 33 | //Console.WriteLine("oj is ready"); 34 | //Console.WriteLine("Breakfast is ready!"); 35 | 36 | Console.WriteLine("------------------------------"); 37 | 38 | Console.WriteLine("A-SYNCHRONOUS METHOD CALLS"); 39 | cup = PourCoffee(); 40 | Console.WriteLine("coffee is ready"); 41 | 42 | Task eggsTask = FryEggsAsync(2); 43 | Task baconTask = FryBaconAsync(3); 44 | Task toastTask = MakeToastWithButterAndJamAsync(2); // composition of async methods 45 | 46 | // changed to MakeToastWithButterAndJamAsync => composition of async functions 47 | //toast = await toastTask; 48 | //ApplyButter(toast); 49 | //ApplyJam(toast); 50 | 51 | oj = PourOJ(); 52 | Console.WriteLine("oj is ready"); 53 | 54 | //best way => putting all the tasks in the list and checking which one done 55 | //by using Task.WhenAny methods and removing from the list 56 | var breakfastTasks = new List { eggsTask, baconTask, toastTask }; 57 | while (breakfastTasks.Count() > 0) 58 | { 59 | var completedTask = await Task.WhenAny(breakfastTasks); 60 | 61 | if (completedTask == eggsTask) 62 | Console.WriteLine("eggs are ready"); 63 | if (completedTask == baconTask) 64 | Console.WriteLine("bacon is ready"); 65 | if (completedTask == toastTask) 66 | Console.WriteLine("toast is ready"); 67 | 68 | breakfastTasks.Remove(completedTask); 69 | } 70 | 71 | //instead of listing all the await task statements 72 | //await Task.WhenAll(eggsTask, baconTask, toastTask); 73 | 74 | //changed to WhenAll method 75 | //eggs = await eggsTask; 76 | //Console.WriteLine("eggs are ready"); 77 | //bacon = await baconTask; 78 | //Console.WriteLine("bacon is ready"); 79 | //toast = await toastTask; 80 | //Console.WriteLine("toast is ready"); 81 | 82 | Console.WriteLine("Breakfast is ready!"); 83 | } 84 | 85 | private static Juice PourOJ() 86 | { 87 | Console.WriteLine("Pouring orange juice"); 88 | return new Juice(); 89 | } 90 | 91 | private static void ApplyJam(Toast toast) => Console.WriteLine("Putting jam on the toast"); 92 | 93 | private static void ApplyButter(Toast toast) => Console.WriteLine("Putting butter on the toast"); 94 | 95 | private static Toast ToastBread(int slices) 96 | { 97 | for (int slice = 0; slice < slices; slice++) 98 | { 99 | Console.WriteLine("Putting a slice of bread in the toaster"); 100 | } 101 | Console.WriteLine("Start toasting..."); 102 | Task.Delay(3000).Wait(); 103 | Console.WriteLine("Remove toast from toaster"); 104 | 105 | return new Toast(); 106 | } 107 | 108 | private static Bacon FryBacon(int slices) 109 | { 110 | Console.WriteLine($"putting {slices} slices of bacon in the pan"); 111 | Console.WriteLine("cooking first side of bacon..."); 112 | Task.Delay(3000).Wait(); 113 | for (int slice = 0; slice < slices; slice++) 114 | { 115 | Console.WriteLine("flipping a slice of bacon"); 116 | } 117 | Console.WriteLine("cooking the second side of bacon..."); 118 | Task.Delay(3000).Wait(); 119 | Console.WriteLine("Put bacon on plate"); 120 | 121 | return new Bacon(); 122 | } 123 | 124 | private static Egg FryEggs(int howMany) 125 | { 126 | Console.WriteLine("Warming the egg pan..."); 127 | Task.Delay(3000).Wait(); 128 | Console.WriteLine($"cracking {howMany} eggs"); 129 | Console.WriteLine("cooking the eggs ..."); 130 | Task.Delay(3000).Wait(); 131 | Console.WriteLine("Put eggs on plate"); 132 | 133 | return new Egg(); 134 | } 135 | 136 | private static Coffee PourCoffee() 137 | { 138 | Console.WriteLine("Pouring coffee"); 139 | return new Coffee(); 140 | } 141 | 142 | //async methods 143 | 144 | private static async Task ToastBreadAsync(int slices) 145 | { 146 | await Task.Run(() => 147 | { 148 | for (int slice = 0; slice < slices; slice++) 149 | { 150 | Console.WriteLine("Putting a slice of bread in the toaster"); 151 | } 152 | Console.WriteLine("Start toasting..."); 153 | Task.Delay(3000).Wait(); 154 | Console.WriteLine("Remove toast from toaster"); 155 | }); 156 | 157 | return new Toast(); 158 | } 159 | 160 | private static async Task FryBaconAsync(int slices) 161 | { 162 | await Task.Run(() => 163 | { 164 | Console.WriteLine($"putting {slices} slices of bacon in the pan"); 165 | Console.WriteLine("cooking first side of bacon..."); 166 | Task.Delay(3000).Wait(); 167 | for (int slice = 0; slice < slices; slice++) 168 | { 169 | Console.WriteLine("flipping a slice of bacon"); 170 | } 171 | Console.WriteLine("cooking the second side of bacon..."); 172 | Task.Delay(3000).Wait(); 173 | Console.WriteLine("Put bacon on plate"); 174 | }); 175 | 176 | return new Bacon(); 177 | } 178 | 179 | private static async Task FryEggsAsync(int howMany) 180 | { 181 | await Task.Run(() => 182 | { 183 | Console.WriteLine("Warming the egg pan..."); 184 | Task.Delay(3000).Wait(); 185 | Console.WriteLine($"cracking {howMany} eggs"); 186 | Console.WriteLine("cooking the eggs ..."); 187 | Task.Delay(3000).Wait(); 188 | Console.WriteLine("Put eggs on plate"); 189 | }); 190 | 191 | return new Egg(); 192 | } 193 | 194 | static async Task MakeToastWithButterAndJamAsync(int number) 195 | { 196 | var toast = await ToastBreadAsync(number); 197 | ApplyButter(toast); 198 | ApplyJam(toast); 199 | 200 | return toast; 201 | } 202 | 203 | } 204 | 205 | internal class Juice 206 | { 207 | } 208 | 209 | internal class Toast 210 | { 211 | } 212 | 213 | internal class Coffee 214 | { 215 | } 216 | 217 | internal class Bacon 218 | { 219 | } 220 | 221 | internal class Egg 222 | { 223 | public int EggId; 224 | } 225 | } -------------------------------------------------------------------------------- /Arrays/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace CSharpBasics 6 | { 7 | class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | 12 | //byte, short, float, int, long, double, decimal, char, bool 13 | //string 14 | //string[] strArray = new[] { "Pune", "Columbia", "Topeka", "Hyderabad", "Philadelphia" }; 15 | 16 | int[] intArray1 = new[] { 6, 23, 3, 44, 53, 4, 71, 8 }; 17 | string[] strArray1 = { "sir_yawnston","CodeWithSean", "CuriousDrive" ,"tbdgamer" }; 18 | 19 | for(int i = 0; i < strArray1.Length; i++) 20 | { 21 | if(i != strArray1.Length-1) 22 | { 23 | strArray1[i+1] += 'c'; 24 | } 25 | Console.WriteLine(strArray1[i]); 26 | } 27 | 28 | 29 | //Array.Sort(strArray1); 30 | // string[] results = strArray1.Reverse().ToArray(); 31 | // foreach (var item in results) 32 | // { 33 | // Console.WriteLine(item); 34 | // } 35 | 36 | //NOTES 37 | // Add below namespaces to use LINQ extension methods 38 | //using System.Collections.Generic; 39 | //using System.Linq; 40 | 41 | 42 | //Array.Sort - ********************* 43 | // this method take array as parameter and sorts it 44 | // for strings it sorts by the 1st char and if the char matches 45 | // then it checks 2nd char 46 | /* 47 | int[] intArray1 = new[] { 6, 23, 3, 44, 53, 4, 71, 8 }; 48 | string[] strArray1 = { "sir_yawnston","CodeWithSean", "CuriousDrive" ,"tbdgamer" }; 49 | 50 | Array.Sort(strArray1); 51 | 52 | foreach (var item in strArray1) 53 | { 54 | Console.WriteLine(item); 55 | }*/ 56 | 57 | //SetValue - ********************* 58 | // this sets the value (which is the first parameter) 59 | // at the index (which is the 2nd parameter) 60 | // it does not check the type of the value that you are setting 61 | //int[] intArray1 = new[] { 1, 2, 3, 4, 5, 6, 7, 8 }; 62 | //intArray1[2] = new object(); 63 | //intArray1[2, 2] = 2; 64 | //intArray1.SetValue(new object(), 1); 65 | //intArray1.SetValue("", 1); 66 | 67 | 68 | // Array.Reverse - ********************* 69 | // this method reverses the array elements in the array 70 | // also this returns void and not the reveresed array 71 | /*int[] intArray1 = new[] { 1, 2, 3, 4, 5, 6, 7, 8 }; 72 | Array.Reverse(intArray1); 73 | 74 | foreach (var item in intArray1) 75 | { 76 | Console.WriteLine(item); 77 | }*/ 78 | 79 | // IndexOf - ********************* 80 | // this returns the position of the first occurence of the element from the array 81 | // LastIndexOf returns the position of the last occurence of element from the array 82 | //int[] intArray1 = new[] { 3, 4, 3, 3, 3, 3, 3, 4 }; 83 | //Console.WriteLine(Array.IndexOf(intArray1, 4)); 84 | 85 | //GetValue - ********************* 86 | // Gets the value at the specified position in the one-dimensional Array 87 | // The index is specified as a 32-bit integer. 88 | //int[] intArray1 = new[] { 1, 2, 3 }; 89 | //Console.WriteLine(intArray1.GetValue(1)); 90 | 91 | 92 | //GetLongLength - ********************* 93 | // int[,,] intArray1 = new[,,] {{{1}},{{1}}}; 94 | // Console.WriteLine(intArray1.GetLength(2)); 95 | 96 | // CopyTo - ********************* 97 | // this method copies elements from calling array to passed array 98 | // it starts copying at the start index 99 | /* 100 | int[] intArray1 = new int[5]; 101 | int[] intArray2 = new int[6]; 102 | 103 | intArray1[0] = 1; 104 | intArray1[1] = 1; 105 | intArray1[2] = 1; 106 | intArray1[3] = 1; 107 | intArray1[4] = 1; 108 | 109 | intArray2[0] = 2; 110 | intArray2[1] = 2; 111 | intArray2[2] = 2; 112 | intArray2[3] = 2; 113 | intArray2[4] = 2; 114 | 115 | foreach (var item in intArray1) 116 | { 117 | Console.Write(item); 118 | } 119 | Console.WriteLine(""); 120 | intArray1.CopyTo(intArray2, 1); 121 | foreach (var item in intArray2) 122 | { 123 | Console.Write(item); 124 | }*/ 125 | 126 | // Array.Copy - ********************* 127 | // this function copies elements from one array to another array 128 | // copy paste starts from the first position 129 | // you pass the number of elements that you want replace as length/count 130 | 131 | /*int[] intArray1 = new int[5]; 132 | int[] intArray2 = new int[5]; 133 | 134 | intArray1[0] = 1; 135 | intArray1[1] = 1; 136 | intArray1[2] = 1; 137 | intArray1[3] = 1; 138 | intArray1[4] = 1; 139 | 140 | intArray2[0] = 2; 141 | intArray2[1] = 2; 142 | intArray2[2] = 2; 143 | intArray2[3] = 2; 144 | intArray2[4] = 2; 145 | 146 | foreach (var item in intArray1) 147 | { 148 | Console.Write(item); 149 | } 150 | Console.WriteLine(""); 151 | Array.Copy(intArray1, intArray2, 6); 152 | foreach (var item in intArray2) 153 | { 154 | Console.Write(item); 155 | }*/ 156 | 157 | // Array.Clear - ********************* 158 | // this function clears the values of array from the start index 159 | // and the length of array that you want to clear 160 | // start index and legth are mandatory parameters 161 | 162 | //Rank - ********************* 163 | // this returns number of dimensions of the array 164 | 165 | //LongLength - ********************* 166 | // this return total value that could be stored in the array 167 | // i.e 3 X 2 = 6 168 | 169 | //cool logic by Sean to replace a char in string - ********************* 170 | //string Name = "Fahadddfgdfgdfgdfgdfgdfg"; 171 | //int pos = 3; 172 | //string newValue = Name.Substring(0, pos) + "e" + Name.Substring(pos + 1); 173 | //Console.WriteLine(newValue); 174 | 175 | // Two Dimension int Array - 176 | // this is how you create/define them 177 | // int[,] intArray = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 } }; 178 | //Console.WriteLine(intArray[2, 1]); 179 | 180 | 181 | //Length - ********************* 182 | // this returns the size of the array. 183 | // it is same as what we assign when we initialize the array 184 | //int[] intArray = new int[10]; 185 | //string[] strArray = new[] { "Pune", "Columbia", "Topeka", "Hyderabad", "Philadelphia" }; 186 | 187 | //Console.WriteLine(intArray.Length); 188 | //Console.WriteLine(strArray.Length); 189 | 190 | 191 | //Properties - - ********************* 192 | // IsFixedSize is always true in case of Array 193 | // IsReadOnly is always false in case of Array 194 | //Console.WriteLine(array.IsFixedSize); 195 | //Console.WriteLine(array.IsReadOnly); 196 | 197 | // Definition - ********************* 198 | // string[] strArray = new[] { "Pune", "Columbia", "Hyderabad", "Philadelphia" }; 199 | // strArray[1] = "Colombia"; 200 | // Console.WriteLine(strArray[1]); 201 | // note : you can not set value of string at particular position 202 | // syntax for accessing the string array particular position 203 | // and char at a string looks the same 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /DataStructures/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace CSharpBasics 7 | { 8 | class Student 9 | { 10 | public string Name { get; set; } 11 | public int Score { get; set; } 12 | } 13 | 14 | class Program 15 | { 16 | static void Main(string[] args) 17 | { 18 | string[] names1 = new[] { "Fahad", "Adam", "Mullaji" }; 19 | string[] names2 = new[] { "Monica", "Kendra", "Mullaji" }; 20 | int[] numbers = { 15, 77, 4, 14, 3}; 21 | string[] stringNumbers = { "11", "12", "13", "14", "15"}; 22 | Student[] students = { new Student() { Score = 10, Name = "Fahad"} , 23 | new Student() { Score = 20, Name = "Monica"}, 24 | new Student() { Score = 20, Name = "Joe"}}; 25 | 26 | numbers.ToList().Select(n => n.ToString()).ToList(); 27 | List intNumbers = stringNumbers.Select(int.Parse).ToList(); 28 | 29 | //-------------------- Stack -------------------- 30 | // Stack languages = new Stack(); 31 | // languages.Push("C#"); 32 | // languages.Push("JavaScript"); 33 | // languages.Push("Java"); 34 | // languages.Push("Python"); 35 | // languages.Push("SQL"); 36 | 37 | //if you try to pop items out of a stack after all the items are popped then it will throw an exception 38 | // Console.WriteLine(languages.Pop()); 39 | // Console.WriteLine(languages.Pop()); 40 | // Console.WriteLine(languages.Pop()); 41 | // Console.WriteLine(languages.Pop()); 42 | // Console.WriteLine(languages.Pop()); 43 | 44 | // this will throw an exception if you try to peek an empty stack 45 | // Console.WriteLine(languages.Peek()); 46 | // Console.WriteLine(languages.Peek()); 47 | // Console.WriteLine(languages.Peek()); 48 | // Console.WriteLine(languages.Peek()); 49 | 50 | //var newLangs = languages.Prepend("Bash"); 51 | 52 | // Console.WriteLine(newLangs.Count()); 53 | //languages.TryPop(); 54 | 55 | // Console.WriteLine(languages.Pop()); 56 | // Console.WriteLine(languages.Pop()); 57 | // Console.WriteLine(languages.Pop()); 58 | // Console.WriteLine(languages.Pop()); 59 | // Console.WriteLine(languages.Pop()); 60 | //Console.WriteLine(languages.Pop()); 61 | 62 | //-------------------- Queue -------------------- 63 | // => Fahad Mark Monica Tanvi Joe Erin Shayna Moo 64 | Queue line = new Queue(); 65 | line.Enqueue("Fahad"); 66 | line.Enqueue("Mark"); 67 | //dequeue method removed the first element in the queue to be removed 68 | //Console.WriteLine(line.Dequeue()); 69 | line.Enqueue("Monica"); 70 | line.Enqueue("Tanvi"); 71 | //Console.WriteLine(line.Dequeue()); 72 | line.Enqueue("Erin"); 73 | line.Enqueue("Shayna"); 74 | //Console.WriteLine(line.Dequeue()); 75 | line.Enqueue("Joe"); 76 | line.Enqueue("Moo"); 77 | 78 | //peek let's you look at the first element but it does not remove the element 79 | // Console.WriteLine(line.Peek()); 80 | // Console.WriteLine(line.Peek()); 81 | // Console.WriteLine(line.Peek()); 82 | 83 | //if tried to dequeue when there are no items then you will get an exception 84 | //Console.WriteLine(line.Dequeue()); 85 | 86 | //you can use TryDequeue to check if there any items left or not 87 | //string result = ""; 88 | //Console.WriteLine(line.TryDequeue(out result)); 89 | //Console.WriteLine(result); 90 | 91 | //if tried to Peek when there are no items then you will get an exception 92 | //Console.WriteLine(line.Peek()); 93 | 94 | //you can use TryPeek to check if there any items left or not 95 | //string result = ""; 96 | //Console.WriteLine(line.TryPeek(out result)); 97 | //Console.WriteLine(result); 98 | 99 | //count of items 100 | //Console.WriteLine(line.Count()); 101 | 102 | //you can convert your queue into a list and work on it 103 | //line.ToList().ForEach(s => Console.WriteLine(s)); 104 | 105 | //-------------------- ARRAY LIST -------------------- 106 | 107 | // Array list is like array but array list is dynamic 108 | // you can add and remove items from the list 109 | // also you can push any type of item at run time 110 | //var arrayList = new ArrayList(); 111 | //var arrayList2 = new ArrayList(); 112 | //var intArray = new int[] {1,2,3 }; 113 | 114 | // Add method 115 | //arrayList.Add(1); 116 | //arrayList.Add(1); 117 | //arrayList2.Add(1); 118 | //arrayList2.Add("Fahad"); 119 | //arrayList2.Add(1); 120 | //arrayList2.Add("Adam"); 121 | //arrayList2.Add("Mullaji"); 122 | 123 | //add range method 124 | //arrayList.AddRange(arrayList2); 125 | //arrayList.AddRange(intArray); 126 | 127 | //accessing items from arraylist 128 | //Console.WriteLine(arrayList[7]); 129 | 130 | //iterate an ArrayList 131 | //foreach (var item in arrayList) 132 | // Console.WriteLine(item); 133 | 134 | //inserting elements in array list 135 | //arrayList.Insert(0, "Fahad"); 136 | 137 | //insert range 138 | //arrayList.InsertRange(0, new string[] { "Adam", "Adam", "Mullaji"}); 139 | 140 | //remove items 141 | //arrayList.Remove("Fahad"); 142 | 143 | //contains method 144 | //Console.WriteLine(arrayList.Contains("Faahad")); 145 | 146 | //foreach (var item in arrayList) 147 | // Console.Write(item); 148 | 149 | //-------------------- DICTIONATY -------------------- 150 | 151 | // Dictionary rollNumberAndName = new Dictionary(); 152 | 153 | // rollNumberAndName.Add(1, "Fahad"); 154 | // rollNumberAndName.Add(2, "Monica"); 155 | // rollNumberAndName.Add(3, "Mark"); 156 | 157 | // rollNumberAndName[1] = "Tanvi"; 158 | 159 | // Console.WriteLine(rollNumberAndName[1]); 160 | 161 | // var list = rollNumberAndName.Select(x => x.Key).ToList(); 162 | 163 | 164 | //-------------------- TUPLES -------------------- 165 | 166 | // List<(int, double)> listValues = new List<(int, double)>(); 167 | 168 | // (int value1, int value2) values = (1,2); 169 | 170 | // listValues.Add((10,10)); 171 | // listValues.Add((10,20)); 172 | // listValues.Add((10,30)); 173 | // listValues.Add((10,40)); 174 | 175 | // foreach (var item in listValues) 176 | // { 177 | // Console.WriteLine(item.Item1 + ":" + item.Item2); 178 | // } 179 | 180 | //-------------------- SORTED LIST -------------------- 181 | 182 | // let's try with numbers first 183 | // the keys gets sorted as the numbers are inserted into the 184 | 185 | // SortedList sortedList = new SortedList(); 186 | // Console.WriteLine("---- Unsorted List ----"); 187 | 188 | // for(int i = 0; i < numbers.Length; i++) 189 | // { 190 | // Console.WriteLine(numbers[i]); 191 | // sortedList.Add(numbers[i], i); 192 | // } 193 | 194 | // Console.WriteLine("---- Sorted List ----"); 195 | // foreach(var item in sortedList.Keys) 196 | // { 197 | // Console.WriteLine(item); 198 | // } 199 | 200 | // this will throw an exception 201 | // sortedList.Add(15,99); 202 | 203 | //-------------------- HASHTABLE -------------------- 204 | 205 | Hashtable numberNames = new Hashtable(); 206 | 207 | numberNames.Add(1,"One"); //adding a key/value using the Add() method 208 | numberNames.Add(2,"Two"); 209 | numberNames.Add(3,"Three"); 210 | 211 | foreach(DictionaryEntry item in numberNames) 212 | { 213 | Console.WriteLine(item.Key + ":" + item.Value); 214 | } 215 | 216 | //-------------------- HASHSET -------------------- 217 | 218 | // HashSet hs = new HashSet(); 219 | 220 | // hs.Add(1); 221 | // hs.Add(3); 222 | // hs.Add(5); 223 | // hs.Add(7); 224 | // hs.Add(9); 225 | 226 | // Console.WriteLine(String.Join('\n', hs)); 227 | } 228 | 229 | // Tuples as method parameters and return types 230 | static (int, string, string) DisplayTuple((int,string,string) person) 231 | { 232 | Console.WriteLine($"Id = { person.Item1}"); 233 | Console.WriteLine($"First Name = { person.Item2}"); 234 | Console.WriteLine($"Last Name = { person.Item3}"); 235 | 236 | return Tuple.Create(1, "Bill", "Gates"); 237 | } 238 | } 239 | } 240 | -------------------------------------------------------------------------------- /ASPNETCoreWebAPI/Models/BookStoresDBContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata; 4 | 5 | #nullable disable 6 | 7 | namespace ASPNETCoreWebAPI.Models 8 | { 9 | public partial class BookStoresDBContext : DbContext 10 | { 11 | public BookStoresDBContext() 12 | { 13 | } 14 | 15 | public BookStoresDBContext(DbContextOptions options) 16 | : base(options) 17 | { 18 | } 19 | 20 | public virtual DbSet Authors { get; set; } 21 | public virtual DbSet Books { get; set; } 22 | public virtual DbSet BookAuthors { get; set; } 23 | public virtual DbSet Jobs { get; set; } 24 | public virtual DbSet Publishers { get; set; } 25 | public virtual DbSet RefreshTokens { get; set; } 26 | public virtual DbSet Roles { get; set; } 27 | public virtual DbSet Sales { get; set; } 28 | public virtual DbSet Stores { get; set; } 29 | public virtual DbSet Users { get; set; } 30 | 31 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 32 | { 33 | if (!optionsBuilder.IsConfigured) 34 | { 35 | //warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263. 36 | optionsBuilder.UseSqlServer("Data Source=.\\sqlexpress;Initial Catalog=BookStoresDB;Integrated Security=True"); 37 | } 38 | } 39 | 40 | protected override void OnModelCreating(ModelBuilder modelBuilder) 41 | { 42 | modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); 43 | 44 | modelBuilder.Entity(entity => 45 | { 46 | entity.ToTable("Author"); 47 | 48 | entity.Property(e => e.AuthorId).HasColumnName("author_id"); 49 | 50 | entity.Property(e => e.Address) 51 | .HasMaxLength(40) 52 | .IsUnicode(false) 53 | .HasColumnName("address"); 54 | 55 | entity.Property(e => e.City) 56 | .HasMaxLength(20) 57 | .IsUnicode(false) 58 | .HasColumnName("city"); 59 | 60 | entity.Property(e => e.EmailAddress) 61 | .HasMaxLength(100) 62 | .IsUnicode(false) 63 | .HasColumnName("email_address"); 64 | 65 | entity.Property(e => e.FirstName) 66 | .IsRequired() 67 | .HasMaxLength(20) 68 | .IsUnicode(false) 69 | .HasColumnName("first_name"); 70 | 71 | entity.Property(e => e.LastName) 72 | .IsRequired() 73 | .HasMaxLength(40) 74 | .IsUnicode(false) 75 | .HasColumnName("last_name"); 76 | 77 | entity.Property(e => e.Phone) 78 | .IsRequired() 79 | .HasMaxLength(12) 80 | .IsUnicode(false) 81 | .HasColumnName("phone") 82 | .HasDefaultValueSql("('UNKNOWN')") 83 | .IsFixedLength(true); 84 | 85 | entity.Property(e => e.State) 86 | .HasMaxLength(2) 87 | .IsUnicode(false) 88 | .HasColumnName("state") 89 | .IsFixedLength(true); 90 | 91 | entity.Property(e => e.Zip) 92 | .HasMaxLength(5) 93 | .IsUnicode(false) 94 | .HasColumnName("zip") 95 | .IsFixedLength(true); 96 | }); 97 | 98 | modelBuilder.Entity(entity => 99 | { 100 | entity.ToTable("Book"); 101 | 102 | entity.Property(e => e.BookId).HasColumnName("book_id"); 103 | 104 | entity.Property(e => e.Advance) 105 | .HasColumnType("money") 106 | .HasColumnName("advance"); 107 | 108 | entity.Property(e => e.Notes) 109 | .HasMaxLength(200) 110 | .IsUnicode(false) 111 | .HasColumnName("notes"); 112 | 113 | entity.Property(e => e.Price) 114 | .HasColumnType("money") 115 | .HasColumnName("price"); 116 | 117 | entity.Property(e => e.PubId).HasColumnName("pub_id"); 118 | 119 | entity.Property(e => e.PublishedDate) 120 | .HasColumnType("datetime") 121 | .HasColumnName("published_date") 122 | .HasDefaultValueSql("(getdate())"); 123 | 124 | entity.Property(e => e.Royalty).HasColumnName("royalty"); 125 | 126 | entity.Property(e => e.Title) 127 | .IsRequired() 128 | .HasMaxLength(80) 129 | .IsUnicode(false) 130 | .HasColumnName("title"); 131 | 132 | entity.Property(e => e.Type) 133 | .IsRequired() 134 | .HasMaxLength(12) 135 | .IsUnicode(false) 136 | .HasColumnName("type") 137 | .HasDefaultValueSql("('UNDECIDED')") 138 | .IsFixedLength(true); 139 | 140 | entity.Property(e => e.YtdSales).HasColumnName("ytd_sales"); 141 | 142 | entity.HasOne(d => d.Pub) 143 | .WithMany(p => p.Books) 144 | .HasForeignKey(d => d.PubId) 145 | .HasConstraintName("FK__Book__pub_id__3E52440B"); 146 | }); 147 | 148 | modelBuilder.Entity(entity => 149 | { 150 | entity.HasKey(e => new { e.AuthorId, e.BookId }); 151 | 152 | entity.ToTable("BookAuthor"); 153 | 154 | entity.Property(e => e.AuthorId).HasColumnName("author_id"); 155 | 156 | entity.Property(e => e.BookId).HasColumnName("book_id"); 157 | 158 | entity.Property(e => e.AuthorOrder).HasColumnName("author_order"); 159 | 160 | entity.Property(e => e.RoyalityPercentage).HasColumnName("royality_percentage"); 161 | 162 | entity.HasOne(d => d.Author) 163 | .WithMany(p => p.BookAuthors) 164 | .HasForeignKey(d => d.AuthorId) 165 | .HasConstraintName("FK__BookAutho__autho__3F466844"); 166 | 167 | entity.HasOne(d => d.Book) 168 | .WithMany(p => p.BookAuthors) 169 | .HasForeignKey(d => d.BookId) 170 | .HasConstraintName("FK__BookAutho__book___403A8C7D"); 171 | }); 172 | 173 | modelBuilder.Entity(entity => 174 | { 175 | entity.ToTable("Job"); 176 | 177 | entity.Property(e => e.JobId).HasColumnName("job_id"); 178 | 179 | entity.Property(e => e.JobDesc) 180 | .IsRequired() 181 | .HasMaxLength(50) 182 | .IsUnicode(false) 183 | .HasColumnName("job_desc") 184 | .HasDefaultValueSql("('New Position - title not formalized yet')"); 185 | }); 186 | 187 | modelBuilder.Entity(entity => 188 | { 189 | entity.HasKey(e => e.PubId) 190 | .HasName("PK__Publishe__2515F2222F169C60"); 191 | 192 | entity.ToTable("Publisher"); 193 | 194 | entity.Property(e => e.PubId).HasColumnName("pub_id"); 195 | 196 | entity.Property(e => e.City) 197 | .HasMaxLength(20) 198 | .IsUnicode(false) 199 | .HasColumnName("city"); 200 | 201 | entity.Property(e => e.Country) 202 | .HasMaxLength(30) 203 | .IsUnicode(false) 204 | .HasColumnName("country") 205 | .HasDefaultValueSql("('USA')"); 206 | 207 | entity.Property(e => e.PublisherName) 208 | .HasMaxLength(40) 209 | .IsUnicode(false) 210 | .HasColumnName("publisher_name"); 211 | 212 | entity.Property(e => e.State) 213 | .HasMaxLength(2) 214 | .IsUnicode(false) 215 | .HasColumnName("state") 216 | .IsFixedLength(true); 217 | }); 218 | 219 | modelBuilder.Entity(entity => 220 | { 221 | entity.HasKey(e => e.TokenId); 222 | 223 | entity.ToTable("RefreshToken"); 224 | 225 | entity.Property(e => e.TokenId).HasColumnName("token_id"); 226 | 227 | entity.Property(e => e.ExpiryDate) 228 | .HasColumnType("datetime") 229 | .HasColumnName("expiry_date"); 230 | 231 | entity.Property(e => e.Token) 232 | .IsRequired() 233 | .HasMaxLength(200) 234 | .IsUnicode(false) 235 | .HasColumnName("token"); 236 | 237 | entity.Property(e => e.UserId).HasColumnName("user_id"); 238 | 239 | entity.HasOne(d => d.User) 240 | .WithMany(p => p.RefreshTokens) 241 | .HasForeignKey(d => d.UserId) 242 | .HasConstraintName("FK__RefreshTo__user___412EB0B6"); 243 | }); 244 | 245 | modelBuilder.Entity(entity => 246 | { 247 | entity.ToTable("Role"); 248 | 249 | entity.Property(e => e.RoleId).HasColumnName("role_id"); 250 | 251 | entity.Property(e => e.RoleDesc) 252 | .IsRequired() 253 | .HasMaxLength(50) 254 | .IsUnicode(false) 255 | .HasColumnName("role_desc") 256 | .HasDefaultValueSql("('New Position - title not formalized yet')"); 257 | }); 258 | 259 | modelBuilder.Entity(entity => 260 | { 261 | entity.ToTable("Sale"); 262 | 263 | entity.Property(e => e.SaleId).HasColumnName("sale_id"); 264 | 265 | entity.Property(e => e.BookId).HasColumnName("book_id"); 266 | 267 | entity.Property(e => e.OrderDate) 268 | .HasColumnType("datetime") 269 | .HasColumnName("order_date"); 270 | 271 | entity.Property(e => e.OrderNum) 272 | .IsRequired() 273 | .HasMaxLength(20) 274 | .IsUnicode(false) 275 | .HasColumnName("order_num"); 276 | 277 | entity.Property(e => e.PayTerms) 278 | .IsRequired() 279 | .HasMaxLength(12) 280 | .IsUnicode(false) 281 | .HasColumnName("pay_terms"); 282 | 283 | entity.Property(e => e.Quantity).HasColumnName("quantity"); 284 | 285 | entity.Property(e => e.StoreId) 286 | .IsRequired() 287 | .HasMaxLength(4) 288 | .IsUnicode(false) 289 | .HasColumnName("store_id") 290 | .IsFixedLength(true); 291 | 292 | entity.HasOne(d => d.Book) 293 | .WithMany(p => p.Sales) 294 | .HasForeignKey(d => d.BookId) 295 | .HasConstraintName("FK__Sale__book_id__4222D4EF"); 296 | 297 | entity.HasOne(d => d.Store) 298 | .WithMany(p => p.Sales) 299 | .HasForeignKey(d => d.StoreId) 300 | .HasConstraintName("FK__Sale__store_id__4316F928"); 301 | }); 302 | 303 | modelBuilder.Entity(entity => 304 | { 305 | entity.ToTable("Store"); 306 | 307 | entity.Property(e => e.StoreId) 308 | .HasMaxLength(4) 309 | .IsUnicode(false) 310 | .HasColumnName("store_id") 311 | .IsFixedLength(true); 312 | 313 | entity.Property(e => e.City) 314 | .HasMaxLength(20) 315 | .IsUnicode(false) 316 | .HasColumnName("city"); 317 | 318 | entity.Property(e => e.State) 319 | .HasMaxLength(2) 320 | .IsUnicode(false) 321 | .HasColumnName("state") 322 | .IsFixedLength(true); 323 | 324 | entity.Property(e => e.StoreAddress) 325 | .HasMaxLength(40) 326 | .IsUnicode(false) 327 | .HasColumnName("store_address"); 328 | 329 | entity.Property(e => e.StoreName) 330 | .HasMaxLength(40) 331 | .IsUnicode(false) 332 | .HasColumnName("store_name"); 333 | 334 | entity.Property(e => e.Zip) 335 | .HasMaxLength(5) 336 | .IsUnicode(false) 337 | .HasColumnName("zip") 338 | .IsFixedLength(true); 339 | }); 340 | 341 | modelBuilder.Entity(entity => 342 | { 343 | entity.HasKey(e => e.UserId) 344 | .HasName("PK_user_id_2") 345 | .IsClustered(false); 346 | 347 | entity.ToTable("User"); 348 | 349 | entity.Property(e => e.UserId).HasColumnName("user_id"); 350 | 351 | entity.Property(e => e.EmailAddress) 352 | .IsRequired() 353 | .HasMaxLength(100) 354 | .IsUnicode(false) 355 | .HasColumnName("email_address"); 356 | 357 | entity.Property(e => e.FirstName) 358 | .HasMaxLength(20) 359 | .IsUnicode(false) 360 | .HasColumnName("first_name"); 361 | 362 | entity.Property(e => e.HireDate) 363 | .HasColumnType("datetime") 364 | .HasColumnName("hire_date") 365 | .HasDefaultValueSql("(getdate())"); 366 | 367 | entity.Property(e => e.LastName) 368 | .HasMaxLength(30) 369 | .IsUnicode(false) 370 | .HasColumnName("last_name"); 371 | 372 | entity.Property(e => e.MiddleName) 373 | .HasMaxLength(1) 374 | .IsUnicode(false) 375 | .HasColumnName("middle_name") 376 | .IsFixedLength(true); 377 | 378 | entity.Property(e => e.Password) 379 | .IsRequired() 380 | .HasMaxLength(100) 381 | .IsUnicode(false) 382 | .HasColumnName("password"); 383 | 384 | entity.Property(e => e.PubId) 385 | .HasColumnName("pub_id") 386 | .HasDefaultValueSql("((1))"); 387 | 388 | entity.Property(e => e.RoleId) 389 | .HasColumnName("role_id") 390 | .HasDefaultValueSql("((1))"); 391 | 392 | entity.Property(e => e.Source) 393 | .IsRequired() 394 | .HasMaxLength(100) 395 | .IsUnicode(false) 396 | .HasColumnName("source"); 397 | 398 | entity.HasOne(d => d.Pub) 399 | .WithMany(p => p.Users) 400 | .HasForeignKey(d => d.PubId) 401 | .HasConstraintName("FK__User__pub_id__44FF419A"); 402 | 403 | entity.HasOne(d => d.Role) 404 | .WithMany(p => p.Users) 405 | .HasForeignKey(d => d.RoleId) 406 | .HasConstraintName("FK__User__role_id__440B1D61"); 407 | }); 408 | 409 | OnModelCreatingPartial(modelBuilder); 410 | } 411 | 412 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder); 413 | } 414 | } 415 | --------------------------------------------------------------------------------