{"id":15035801,"url":"https://github.com/ahotko/c-sharp-code-examples","last_synced_at":"2025-04-09T23:20:18.130Z","repository":{"id":178931435,"uuid":"186373158","full_name":"ahotko/c-sharp-code-examples","owner":"ahotko","description":"C# Code Examples / Snippets","archived":false,"fork":false,"pushed_at":"2021-06-15T11:41:03.000Z","size":151,"stargazers_count":48,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T01:11:11.569Z","etag":null,"topics":["c-sharp","c-sharp-learning","code-sample","code-samples","csharp-code","csharp-notes","csharp-resources","design-patterns","designpatterns","solid-principles"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ahotko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-13T08:01:47.000Z","updated_at":"2025-01-25T15:22:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"651ef32e-c818-4a31-8852-02d5aa6ce49b","html_url":"https://github.com/ahotko/c-sharp-code-examples","commit_stats":null,"previous_names":["ahotko/c-sharp-code-examples"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahotko%2Fc-sharp-code-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahotko%2Fc-sharp-code-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahotko%2Fc-sharp-code-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahotko%2Fc-sharp-code-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahotko","download_url":"https://codeload.github.com/ahotko/c-sharp-code-examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248126108,"owners_count":21051870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","c-sharp-learning","code-sample","code-samples","csharp-code","csharp-notes","csharp-resources","design-patterns","designpatterns","solid-principles"],"created_at":"2024-09-24T20:29:31.128Z","updated_at":"2025-04-09T23:20:18.102Z","avatar_url":"https://github.com/ahotko.png","language":"C#","readme":"# C# Code Examples (mostly for myself)\n\nA collection of code samples I have used C# and think they might be useful in the future.\n\n## Sample Categories\n* [Abstract Class](CSharp%20Code%20Samples/CodeSamples/SampleExecute.cs)\n* [Anonymous Types](CSharp%20Code%20Samples/CodeSamples/Classes/AnonymousTypesSample.cs)\n* [Attributes and Conditionals](CSharp%20Code%20Samples/CodeSamples/Attributes)\n  * [Debugger](CSharp%20Code%20Samples/CodeSamples/Attributes/DebuggingSample.cs)\n    * [`DebuggerDisplay`](CSharp%20Code%20Samples/CodeSamples/Attributes/DebuggingSample.cs)\n\t* [`DebuggerBrowsable`](CSharp%20Code%20Samples/CodeSamples/Attributes/DebuggingSample.cs)\n\t* [`Conditional`](CSharp%20Code%20Samples/CodeSamples/Attributes/DebuggingSample.cs)\n\t* [`#if - #define - #endif`](CSharp%20Code%20Samples/CodeSamples/Attributes/DebuggingSample.cs)\n  * [`Obsolete`](CSharp%20Code%20Samples/CodeSamples/Attributes/ObsoleteSample.cs)\n    * [Compiler Warning](CSharp%20Code%20Samples/CodeSamples/Attributes/ObsoleteSample.cs)\n\t* [Compiler Error](CSharp%20Code%20Samples/CodeSamples/Attributes/ObsoleteSample.cs)\n  * [`Conditional`](CSharp%20Code%20Samples/CodeSamples/Attributes/ConditionalSample.cs)\n* [Classes](CSharp%20Code%20Samples/CodeSamples/Classes)\n  * [Get current Class name](CSharp%20Code%20Samples/CodeSamples/Classes/ClassAndMethodNamesSample.cs#L9)\n  * [Get current Method Name](CSharp%20Code%20Samples/CodeSamples/Classes/ClassAndMethodNamesSample.cs#L10)\n  * [Constructor Chaining](CSharp%20Code%20Samples/CodeSamples/Classes/ConstructorChainingSample.cs)\n  * [Caller Info](CSharp%20Code%20Samples/CodeSamples/Classes/CallerInfoSample.cs)\n* [Comparing](CSharp%20Code%20Samples/CodeSamples/Classes)\n  * [`IEquatable\u003cT\u003e`](CSharp%20Code%20Samples/CodeSamples/Comparing/Equatable.cs) Additional links: [Link](https://bettersolutions.com/csharp/interfaces/iequatable.htm)\n  * [`IEqualityComparer\u003cT\u003e`](CSharp%20Code%20Samples/CodeSamples/Comparing/EqualityComparer.cs) Additional links: [Link](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iequalitycomparer-1)\n* [Design Patterns](CSharp%20Code%20Samples/CodeSamples/Patterns)\n  * Creational Patterns\n\t* [Singleton Pattern](CSharp%20Code%20Samples/CodeSamples/Patterns/Creational/SingletonPattern.cs)\n\t* [Factory Method Pattern](CSharp%20Code%20Samples/CodeSamples/Patterns/Creational/FactoryMethodPattern.cs)\n\t* [Abstract Factory Pattern](CSharp%20Code%20Samples/CodeSamples/Patterns/Creational/AbstractFactoryPattern.cs)\n  * Behavioral Patterns\n\t* [Strategy Pattern](CSharp%20Code%20Samples/CodeSamples/Patterns/Behavioral/StrategyPattern.cs)\n\t* [Observer Pattern](CSharp%20Code%20Samples/CodeSamples/Patterns/Behavioral/ObserverPattern.cs)\n\t* [State Pattern](CSharp%20Code%20Samples/CodeSamples/Patterns/Behavioral/StatePattern.cs)\n* [Dictionaries](CSharp%20Code%20Samples/CodeSamples/UsefulClasses/Dictionaries.cs)\n  * [`Dictionary`](CSharp%20Code%20Samples/CodeSamples/UsefulClasses/Dictionaries.cs#L42) Additional links: [Link](https://www.dotnetperls.com/dictionary)\n  * [`OrderedDictionary`](CSharp%20Code%20Samples/CodeSamples/UsefulClasses/Dictionaries.cs#L50) (requires [`System.Collections.Specialized`](https://www.nuget.org/packages/System.Collections.Specialized/)); Additional links: [Link](https://www.geeksforgeeks.org/c-sharp-ordereddictionary-class/)\n  * [`SortedDictionary`](CSharp%20Code%20Samples/CodeSamples/UsefulClasses/Dictionaries.cs#L65) Additional links: [Link](https://www.dotnetperls.com/sorteddictionary)\n* [Extension Methods](CSharp%20Code%20Samples/CodeSamples/Alterations/Extensions/ClassExtensionSample.cs)\n* [Garbage Collection](CSharp%20Code%20Samples/CodeSamples/Useful/GarbageCollectionSample.cs) \n* [Implicit/Explicit Conversion operators](CSharp%20Code%20Samples/CodeSamples/Alterations/EntityConversionSample.cs)\n* [Interface](CSharp%20Code%20Samples/CodeSamples/ISampleExecute.cs)\n* [`LINQ`](CSharp%20Code%20Samples/CodeSamples/Useful/LinqSample.cs)\n  * Sum\n  * Sum by Groups\n  * Ordering (asc, desc)\n  * Skipping\n  * Take N elements\n  * Select Samples with value between \n* [Object Pool](CSharp%20Code%20Samples/CodeSamples/UsefulClasses/ObjectPoolSample.cs)\n* [Operator Overloading](CSharp%20Code%20Samples/CodeSamples/Alterations/OperatorOverloadingSample.cs) Additional links: [Link](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/operator-overloading)\n* [SOLID](CSharp%20Code%20Samples/CodeSamples/SOLID)\n  * [Single Responsibility Principle](CSharp%20Code%20Samples/CodeSamples/SOLID/S01-SingleResponsibilityPrinciple_SRP)\n  * [Inversion of Control](CSharp%20Code%20Samples/CodeSamples/SOLID/S04-InversionOfControl_IoC)\n* [Syntactic Sugars](CSharp%20Code%20Samples/CodeSamples/SyntacticSugars)\n  * [Auto Property](CSharp%20Code%20Samples/CodeSamples/SyntacticSugars/PropertiesSample.cs#L34)\n  * [Auto Property with default value](CSharp%20Code%20Samples/CodeSamples/SyntacticSugars/PropertiesSample.cs#L35)\n  * [Property getter/setter](CSharp%20Code%20Samples/CodeSamples/SyntacticSugars/PropertiesSample.cs#L11)\n  * [String Interpolation](CSharp%20Code%20Samples/CodeSamples/SyntacticSugars/StringInterpolationSample.cs)\n  * [Using](CSharp%20Code%20Samples/CodeSamples/SyntacticSugars/UsingSample.cs)\n  * [Pattern Matching](CSharp%20Code%20Samples/CodeSamples/SyntacticSugars/PatternMatchingSample.cs)\n* [Threading](CSharp%20Code%20Samples/CodeSamples/MultiThreading)\n  * [`BackgroundWorker`](CSharp%20Code%20Samples/CodeSamples/MultiThreading/BackgroundWorkerSample.cs)\n  * [`Thread`](CSharp%20Code%20Samples/CodeSamples/MultiThreading/ThreadSample.cs)\n* [Timing](CSharp%20Code%20Samples/CodeSamples/Timing)\n* [Tuple Deconstruction](CSharp%20Code%20Samples/CodeSamples/TupleDeconstruction) (requires [`System.ValueTuple`](https://www.nuget.org/packages/System.ValueTuple/)); Additional links: [Link](https://docs.microsoft.com/en-us/dotnet/csharp/deconstruct)\n\n  \n## Useful Libraries\n\n### Universal\n* Excel (Native)\n  * [EPPlus](https://github.com/JanKallman/EPPlus)\n* QR Codes\n  * [QRCoder](https://github.com/codebude/QRCoder)\n* PDF\n  * [PdfFileWriter.NET](https://github.com/jeske/PdfFileWriter.NET)\n* JSON\n  * [Json.NET](https://www.newtonsoft.com/json)\n  * [Jil - Fast .NET JSON (De)Serializer, Built On Sigil](https://github.com/kevin-montrose/Jil)\n* Logging\n  * [NLog](https://nlog-project.org/)\n* ORM\n  * [AutoMapper](https://automapper.org/)\n  \n### WPF Specific\n* UI/UX\n  * Frameworks\n    * [MahApps.Metro](https://github.com/MahApps/MahApps.Metro)\n\t* [Modern UI for WPF](https://github.com/firstfloorsoftware/mui)\n  * Iconpacks\n    * [MahApps.IconPack](https://github.com/MahApps/MahApps.Metro.IconPacks)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahotko%2Fc-sharp-code-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahotko%2Fc-sharp-code-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahotko%2Fc-sharp-code-examples/lists"}