This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RelayCommandAsync<T> : ICommand | |
{ | |
private readonly Func<T, Task> executedMethod; | |
private readonly Func<T, bool> canExecuteMethod; | |
public event EventHandler CanExecuteChanged; | |
public RelayCommandAsync(Func<T, Task> execute) : this(execute, null) { } | |
public RelayCommandAsync(Func<T, Task> execute, Func<T, bool> canExecute) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string ReplaceLetters(string wordToSearch, char letterToFind, char letterToReplace) | |
{ | |
StringBuilder word = new StringBuilder(wordToSearch); | |
int index = 0; | |
foreach (char letter in wordToSearch) | |
{ | |
if (letter.Equals(letterToFind)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void CalculateAverage() | |
{ | |
// Create and populate the list of numbers | |
List<double> values = new List<double>(); | |
values.Add(1); | |
values.Add(5); | |
values.Add(21); | |
// Calculating the average, using a foreach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class RandomNumberGenerator | |
{ | |
private static readonly RNGCryptoServiceProvider _generator = new RNGCryptoServiceProvider(); | |
public static int NumberBetween(int minimumValue, int maximumValue) | |
{ | |
byte[] randomNumber = new byte[1]; | |
_generator.GetBytes(randomNumber); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class CopyObject | |
{ | |
public static void ShallowCopy(this Object dst, object src) | |
{ | |
var srcT = src.GetType(); | |
var dstT = dst.GetType(); | |
foreach (var f in srcT.GetFields()) | |
{ | |
var dstF = dstT.GetField(f.Name); | |
if (dstF == null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void buttonLoadFile_Click(object sender, EventArgs e) | |
{ | |
OpenFileDialog ofd = new OpenFileDialog(); | |
ofd.Title = "Open File"; | |
ofd.Filter = "All Files (*.*)|*.*"; | |
textBoxName.Text = ofd.SafeFileName; | |
textBoxLocation.Text = ofd.FileName; | |
if (ofd.ShowDialog() == DialogResult.OK) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void DoFizzBuzz() | |
{ | |
for (int i = 1; i <= 100; i++) | |
{ | |
bool fizz = i % 3 == 0; | |
bool buzz = i % 5 == 0; | |
if (fizz && buzz) | |
Console.WriteLine ("FizzBuzz"); | |
else if (fizz) | |
Console.WriteLine ("Fizz"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private long CalculatePower(int Number, int PowerOf) | |
{ | |
long Result = Number; | |
for (int i = PowerOf; i > 1; i--) | |
{ | |
Result = (Result * Number); | |
} | |
return Result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int this.age; | |
public int Age | |
{ | |
get | |
{ | |
return this.age; | |
} | |
set | |
{ |