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 void ShowUserBalance(object balance) | |
{ | |
if (balance is decimal userBalance || (balance is string s && decimal.TryParse(s, out userBalance))) | |
{ | |
Console.WriteLine($"Kullanıcının bakiyesi {userBalance}"); | |
} | |
} |
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
switch(shape) | |
{ | |
case Circle c: | |
WriteLine($"circle with radius {c.Radius}"); | |
break; | |
case Rectangle s when (s.Length == s.Height): | |
WriteLine($"{s.Length} x {s.Height} square"); | |
break; | |
case Rectangle r: | |
WriteLine($"{r.Length} x {r.Height} rectangle"); |
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 int Fibonacci(int x) | |
{ | |
if (x < 0) throw new ArgumentException("Less negativity please!", nameof(x)); | |
{ | |
return Fib(x).current; | |
} | |
(int current, int previous) Fib(int i) | |
{ | |
if (i == 0) return (1, 0); |
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 ref int Find(int number, int[] numbers) | |
{ | |
for (int i = 0; i < numbers.Length; i++) | |
{ | |
if (numbers[i] == number) | |
{ | |
return ref numbers[i]; // burada dönülen aslında i. elemanın değeri değil onun array içerisindeki referansı | |
} | |
} | |
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 Square | |
{ | |
public Square(int length) | |
{ | |
Length = length; | |
} | |
~Square() // Örnek amaçlı yazıldı | |
{ | |
Length = 0; |
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 Square | |
{ | |
public Square(int length) => Length = length; | |
~Square() => Length = 0; // Örnek amaçlı yazıldı | |
public int Length { get; set; } | |
public int Area => Length * Length; | |
public int Perimeter => 4 * Length; | |
public override string ToString() => $"Square: Area={Area}, Perimeter={Perimeter}"; | |
} |
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
class Person | |
{ | |
public string Name { get; } | |
public Person(string name) => Name = name ? ? throw new ArgumentNullException(name); | |
public string GetFirstName() | |
{ | |
var parts = Name.Split(" "); | |
return (parts.Length > 0) ? parts[0] : throw new InvalidOperationException("No name!"); | |
} |
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 BankOperations : IBankOperations | |
{ | |
private readonly ILogger _logger; | |
private readonly IExceptionHandling _exceptionHandling; | |
private readonly ISecurityService _securityService; | |
private readonly IAccountOperations _accountOperations; | |
public BankOperations(ILogger logger, IExceptionHandling exceptionHandling, ISecurityService securityService, IAccountOperations accountOperations) | |
{ | |
_logger = logger; |
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 BankOperations : IBankOperations | |
{ | |
private readonly IAccountOperations _accountOperations; | |
public BankOperations(IAccountOperations accountOperations) | |
{ | |
_accountOperations = accountOperations; | |
} | |
public void Transfer(string fromAccountNumber, string toAccountNumber, decimal ammount) |
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 LoggingAspect : OnMethodBoundaryAspect | |
{ | |
public override void OnEntry(MethodExecutionArgs args) | |
{ | |
ILogger logger = new Logger(); | |
logger.LogOperation(args.Method.Name, args[0], args[1], args[2]); | |
} | |
// Diğer methodlar, bilgilendirme amaçlı | |