Skip to content

Instantly share code, notes, and snippets.

View poojarsn's full-sized avatar

santosh poojari poojarsn

View GitHub Profile
@poojarsn
poojarsn / JoinAndSetOperation.cs
Created April 22, 2020 05:36
Join and Set operation
namespace FileProcessor
{
class Program
{
static void Main(string[] args)
{
JoinNamesAndAges();
SetOperations();
@poojarsn
poojarsn / ImmutableDictionary.cs
Created April 22, 2020 01:39
Immutable Dictionary
public class AppData
{
public ImmutableArray<Country> AllCountries { get; private set; }
public ImmutableDictionary<CountryCode, Country> AllCountriesByKey
{ get; private set; }
public void Initialize(string csvFilePath)
{
CsvReader reader = new CsvReader(csvFilePath);
var countries = reader.ReadAllCountries().OrderBy(x=>x.Name).ToList();
@poojarsn
poojarsn / dictionary.cs
Created April 21, 2020 05:55
c# Dictionary Example
public class AppData
{
public List<Country> AllCountries { get; private set; }
public Dictionary<CountryCode, Country> AllCountriesByKey { get; private set; }
public void Initialize(string csvFilePath)
{
CsvReader reader = new CsvReader(csvFilePath);
this.AllCountries = reader.ReadAllCountries().OrderBy(x => x.Name).ToList();
var dict = AllCountries.ToDictionary(x => x.Code);
this.AllCountriesByKey = dict;
@poojarsn
poojarsn / Population.csv
Created April 21, 2020 03:04
Csv file for population
Country Name Country Code Continent Population 2017
China CHN Asia 1386395000
India IND Asia 1339180127
United States USA North America 325719178
Indonesia IDN Asia 263991379
Brazil BRA South America 209288278
Pakistan PAK Asia 197015955
Nigeria NGA Africa 190886311
Bangladesh BGD Asia 164669751
Russian Federation RUS Europe 144495044
@poojarsn
poojarsn / readCsv.cs
Last active April 21, 2020 03:03
C# Read CSV and list collection
public class AppData
{
public List<Country> AllCountries { get; private set; }
public void Initialize(string csvFilePath)
{
CsvReader reader = new CsvReader(csvFilePath);
this.AllCountries = reader.ReadAllCountries();
// during the module, the above line is changed to
//this.AllCountries = reader.ReadAllCountries().OrderBy(x=>x.Name).ToList();
@poojarsn
poojarsn / CompareArray.cs
Created April 21, 2020 01:17
c# Array Comparison
using System;
public class Program
{
public static void Main()
{
DateTime[] bankHols1 ={
new DateTime(2021, 1, 1),
new DateTime(2021, 4, 2),
new DateTime(2021, 4, 5)
};
@poojarsn
poojarsn / LocalMethod.cs
Created April 20, 2020 05:17
c#Local Method
using System;
public class Program
{
public static void Main()
{
ProcessMyStringTuple("san");
void ProcessMyStringTuple(string name)
{
@poojarsn
poojarsn / LocalMethod.cs
Created April 20, 2020 05:17
c#Local Method
using System;
public class Program
{
public static void Main()
{
ProcessMyStringTuple("san");
void ProcessMyStringTuple(string name)
{
@poojarsn
poojarsn / TupleOutputMethod.cs
Last active April 20, 2020 05:14
Method with Tuple output params
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
var result = ProcessMyStringTuple("san");
Console.WriteLine($"Length :{result.length} , Name in Upper case : {result.upperCaseName}");
@poojarsn
poojarsn / GuessGame
Created April 1, 2020 02:37
Guess.html
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div style="text-align:center">
<h1> ESP Test</h1>