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
Task.Run(ProcessWriteAsync); // main function call | |
async Task ProcessWriteAsync() | |
{ | |
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; | |
string subPath = @"logs\"; | |
string fileName = $@"chatlogs.txt"; | |
DirectoryInfo directoryInfo = new(baseDirectory); |
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
using System; | |
using System.Threading; | |
static class Program { | |
static void Main() { | |
Console.Write("Performing some task... "); | |
using (var progress = new ProgressBar()) { | |
for (int i = 0; i <= 100; i++) { | |
progress.Report((double) i / 100); |
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
//If-Else Approach | |
public static class ParserFactory | |
{ | |
public static IFileParser Create(string filename) | |
{ | |
var extension = Path.GetExtension(fileName); | |
if (extension == ".json") | |
{ | |
return new JsonParser(); |
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
//If-Else Approach | |
public enum Reaction | |
{ | |
Initial = 1, | |
Liked = 2, | |
Disliked = 3 | |
} | |
public class LikeDislikeComponent | |
{ |
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
//If-Else Approach | |
public class User | |
{ | |
public string Name { get; set; } | |
public string Email { get; set; } | |
public void ChangeEmail(string email) | |
{ | |
if (!IsEmailValid(email)) | |
throw new ArgumentException("{email} is not valid.", email); |
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 interface IReader<T> where T : notnull | |
{ | |
IReadOnlyCollection<T> GetElements(); | |
T GetElementAt(int index) => GetElements().ElementAtOrDefault(index); | |
} | |
public record FibonacciReader : IReader<int> | |
{ | |
public IReadOnlyCollection<int> GetElements() => new FibonacciSequence().ToList(); | |
} |
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 Rect(decimal x, decimal y, decimal width, decimal height) | |
{ | |
X = x; | |
Y = y; | |
Width = width; | |
Height = height; | |
} | |
/// <summary> | |
/// The x coordinate of the element in pixels. |
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 void Main() | |
{ | |
foreach (var num in Fibonacci(7)) | |
{ | |
Console.WriteLine(num); | |
} | |
} | |
protected static IEnumerable<uint> Fibonacci(uint number) | |
{ |
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
internal class HightTier { } | |
internal class MediumTier : HightTier { } | |
internal class LowTier : MediumTier { } | |
internal delegate Covariance TierHandler<Invariance, in Contravariance, out Covariance>(Contravariance arg); | |
/// <summary> | |
/// if 1st_op = 2nd_op | |
/// then | |
/// <in> is tantamount to Going UP (emerged from MediumTier to HightTier) |
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
<PropertyGroup> | |
<Nullable>enable</Nullable> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp3.1</TargetFramework> | |
</PropertyGroup> | |
public class AmplifiedAction | |
{ | |
private Action _action; |
NewerOlder