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.ComponentModel; | |
namespace TODO.Models; | |
public partial class Customer : INotifyPropertyChanged | |
{ | |
public string FirstName | |
{ | |
get => _firstName; | |
set => SetField(ref _firstName, value); |
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.ComponentModel; | |
#pragma warning disable CA1067 | |
namespace YourNamespace.Models; | |
public class Person : INotifyPropertyChanged, IEquatable<Person> | |
{ | |
private int _id; | |
private string _firstName; |
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.Text.RegularExpressions; | |
public static partial class StringHelpers | |
{ | |
public static string FormatSocial1(string value) | |
{ | |
if (string.IsNullOrEmpty(value)) | |
return value; |
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 Customer : INotifyPropertyChanged | |
{ | |
private string _firstName; | |
private string _lastName; | |
private DateOnly _birthDate; | |
public string FirstName | |
{ | |
get => _firstName; | |
set |
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 CommonHelpers | |
{ | |
public static string GetSeason(int month) => $"The season is {month switch | |
{ | |
1 or 2 or 12 => "winter", | |
> 2 and < 6 => "spring", | |
> 5 and < 9 => "summer", | |
> 8 and < 12 => "autumn", | |
_ => "unknown.", | |
}}."; |
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
var paths = Environment.GetEnvironmentVariable("Path")!.Split(";"); | |
foreach (var (part, index) in paths.Select((part, index) => (value: part, i: index))) | |
{ | |
Console.WriteLine($"{index,-3}{part}"); | |
} |
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
string firstLastName = "KarenPayne"; | |
var separated = firstLastName.SplitByCase(); |
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 TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; | |
static List<string> names = ["KaRen", "YelEna", "BiLL"]; | |
private static void CaseInsensitiveDictionary1() | |
{ | |
Dictionary<string, string> userDictionary = new(StringComparer.InvariantCultureIgnoreCase) | |
{ { "karen", "Developer advocate" }, { "yelena", "Manager" }, { "bill", "Web master" }, }; | |
foreach (var name in names) |
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 StringExtensions | |
{ | |
public static string? FirstCharacterToLowerCase(this string? sender) | |
{ | |
if (!string.IsNullOrEmpty(sender) && char.IsUpper(sender[0])) | |
{ | |
return sender.Length == 1 ? | |
char.ToLower(sender[0]).ToString() : | |
$"{char.ToLower(sender[0])}{sender[1..]}"; | |
} |
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.Globalization; | |
using System.Text.RegularExpressions; | |
namespace ConsoleApp1; | |
internal partial class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var input = "Enter anything 12 and I will try 44 to detect any number (leave empty 1 to exit):"; |
NewerOlder