Skip to content

Instantly share code, notes, and snippets.

@miteshsureja
miteshsureja / Program.cs
Created May 21, 2017 13:00
Display Prime Numbers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RandomNumbers
{
class Program
{
@miteshsureja
miteshsureja / Program.cs
Created May 21, 2017 13:11
Program to display series - 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RandomNumbers
{
class Program
{
@miteshsureja
miteshsureja / Program.cs
Created May 21, 2017 13:04
Find Max and Min value from List
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RandomNumbers
{
class Program
{
@miteshsureja
miteshsureja / ParallelInvoke
Created April 30, 2017 14:09
Parallel.Invoke
namespace ParallelInvoke
{
using System.Threading;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Parallel.Invoke(() =>
{
@miteshsureja
miteshsureja / Program.cs
Created March 8, 2017 14:20
How to handle exception in Parallel.For and Parallel.Foreach loop? – Task Parallel Library
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Concurrent;
namespace ParallelFor
{
class Program
{
static void Main(string[] args)
@miteshsureja
miteshsureja / Program.cs
Created March 8, 2017 13:53
How to cancel a Parallel.For and Parallel.Foreach loop – Task Parallel Library
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System;
using System.Threading.Tasks;
using System.Threading;
namespace ParallelFor
{
@miteshsureja
miteshsureja / BuyCommand.cs
Created May 1, 2017 12:46
Command Pattern
//Concrete Command class
public class BuyCommand : ICommand
{
private Product Product;
public string Name
{
get
{
return "Buy Command";
}
@miteshsureja
miteshsureja / MainWindow.xaml
Created May 29, 2017 13:39
Async and Await - Asynchronous Programming
<Window x:Class="AsyncAwaitExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AsyncAwaitExample"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<TextBlock Text="Enter number to sum:" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,50,0,0"/>
@miteshsureja
miteshsureja / Aggregate.cs
Created June 11, 2017 07:52
Iterator Design Pattern Example
using System;
using System.Collections;
using System.Collections.Generic;
namespace IteratorPattern
{
//Aggregate
public abstract class Aggregate
{
public abstract Iterator GetIterator();
@miteshsureja
miteshsureja / MyCollection.cs
Created June 11, 2017 07:55
Iterator Pattern using IEnumerable example
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IteratorPattern
{
public class MyCollection : IEnumerable
{