{"id":27019130,"url":"https://github.com/jabbalaci/jabbacustomextensions-for-c-sharp","last_synced_at":"2025-06-25T19:02:41.034Z","repository":{"id":140437504,"uuid":"127902881","full_name":"jabbalaci/JabbaCustomExtensions-for-C-Sharp","owner":"jabbalaci","description":"My own extensions for C#. Inspired by Python, Kotlin, etc.","archived":false,"fork":false,"pushed_at":"2020-08-01T09:51:30.000Z","size":40,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-25T19:02:23.458Z","etag":null,"topics":["csharp","extensions","kotlin","python"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jabbalaci.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,"zenodo":null}},"created_at":"2018-04-03T12:14:00.000Z","updated_at":"2021-11-15T00:42:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"87a5170d-c694-47f7-9f34-d0d9eea28d06","html_url":"https://github.com/jabbalaci/JabbaCustomExtensions-for-C-Sharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jabbalaci/JabbaCustomExtensions-for-C-Sharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2FJabbaCustomExtensions-for-C-Sharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2FJabbaCustomExtensions-for-C-Sharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2FJabbaCustomExtensions-for-C-Sharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2FJabbaCustomExtensions-for-C-Sharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jabbalaci","download_url":"https://codeload.github.com/jabbalaci/JabbaCustomExtensions-for-C-Sharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2FJabbaCustomExtensions-for-C-Sharp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261937022,"owners_count":23232843,"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":["csharp","extensions","kotlin","python"],"created_at":"2025-04-04T17:19:10.221Z","updated_at":"2025-06-25T19:02:40.991Z","avatar_url":"https://github.com/jabbalaci.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Jabba's Custom Extensions for C#\n================================\n\nMy own extensions for C#. Inspired by Python, Kotlin, etc.\n\nLet's see some examples as an appetizer.\n\nString methods\n--------------\n\nCapitalize a string\n\n```cs\ncsi\u003e \"whatever\".Capitalize();\n\"Whatever\"\n```\n\nReverse a string\n\n```cs\ncsi\u003e \"abcd\".ReverseStr();\n\"dcba\"\n```\n\nString slicing, supporting negative indexing and step\n\n```cs\ncsi\u003e var s1 = \"Fallout: New Vegas\";\n\ncsi\u003e s1.Slice(0, 4);\n\"Fall\"\ncsi\u003e s1.Slice(4, 7);\n\"out\"\ncsi\u003e s1.Slice(-3, s1.Length);\n\"gas\"\ncsi\u003e s1.Slice(-5, -1);\n\"Vega\"\n\n\ncsi\u003e var s2 = \"python programming\";\n\ncsi\u003e s2.Slice(0, s1.Length, 2);\n\"pto rgamn\"\ncsi\u003e s2.Slice(0, 6, 2);\n\"pto\"\n```\n\nString multiplication\n\n```cs\ncsi\u003e \"x\".Times(3);\n\"xxx\"\n```\n\nCenter a text\n\n```cs\ncsi\u003e \"*\".Center(10);\n\"    *     \"\ncsi\u003e \"***\".Center(10, '.');\n\"...***....\"\n```\n\nString to int\n\n```cs\ncsi\u003e \"42\".ToInt();\n42\n```\n\nString splitting\n\n```cs\ncsi\u003e var s4 = \"   aa     bb    \\t    cc        dd\\n    \";\ncsi\u003e s4.SplitAndRemoveEmptyEntries();\n{\"aa\", \"bb\", \"cc\", \"dd\"}    // array of strings\n```\n\nList methods\n------------\n\nList slicing, supporting negative indexing and step\n\n```cs\ncsi\u003e var li1 = new List\u003cchar\u003e { 'a', 'b', 'c', 'd', 'e', 'f', 'g' };\n\ncsi\u003e li1.Slice(2, 4);\n{'c', 'd'}    // list of chars\ncsi\u003e li1.Slice(2, -2);\n{'c', 'd', 'e'}\n\ncsi\u003e li1.Slice(0, 5, 2);\n{'a', 'c', 'e'}\n```\n\nPretty print\n------------\n\nPretty print an array, a list, etc. Good for debugging.\n\n```cs\ncsi\u003e var seq3 = new List\u003cint\u003e() { 1, 5, 8 };\ncsi\u003e Console.WriteLine(seq3);\nSystem.Collections.Generic.List`1[System.Int32]    // ugly\ncsi\u003e Console.WriteLine(seq3.Pretty());\n[1, 5, 8]                                          // nice\n\ncsi\u003e var seq5 = new List\u003cstring\u003e() { \"aa\", \"bb\" };\ncsi\u003e Console.WriteLine(seq5.Pretty());\n[\"aa\", \"bb\"]    // notice the quotes\n\ncsi\u003e var seq6 = new List\u003cstring\u003e() { 'a', 'b' };\ncsi\u003e Console.WriteLine(seq6.Pretty());\n['a', 'b']    // notice the apostrophes\n\ncsi\u003e Console.WriteLine(Enumerable.Range(1, 5).Pretty());\n[1, 2, 3, 4, 5]\n```\n\nSome Python built-in functions\n------------------------------\n\nRanges\n\n```cs\ncsi\u003e Py.RangeExcl(10, 15).ToArray();\n{10, 11, 12, 13, 14}    // array of ints, 15 excluded\n\ncsi\u003e Py.RangeIncl(10, 15).ToArray();\n{10, 11, 12, 13, 14, 15}    // array of ints, 15 included\n```\n\nZip\n\n```cs\ncsi\u003e int[] numbers = { 1, 2, 3, 4 };\ncsi\u003e string[] words = { \"one\", \"two\", \"three\" };\ncsi\u003e char[] chars = { 'a', 'b', 'c', 'd', 'e', 'f' };\n\ncsi\u003e Py.Zip(numbers, words);\n[(1, \"one\"), (2, \"two\"), (3, \"three\")]    // an iterator over these tuples\n\ncsi\u003e Py.Zip(numbers, words, chars);\n[(1, \"one\", 'a'), (2, \"two\", 'b'), (3, \"three\", 'c')]    // an iterator over these tuples\n```\n\nSorting\n\n```cs\ncsi\u003e var numbers = new List\u003cint\u003e { 4, 2, 3, 1 };\ncsi\u003e Py.Sorted(numbers);    // returns a sorted copy\n{ 1, 2, 3, 4}\ncsi\u003e numbers\n{ 4, 2, 3, 1 }    // the original list is not changed\n```\n\n----------\n\nThe list is not complete. See also the [sources](JabbaCustomExtensions) and the [tests](JabbaCustomExtensionsTest).\n\nHow to use it?\n--------------\n\n```cs\nusing static System.Console;\nusing JabbaCustomExtensions;    // \"import\" it\n\nnamespace Hello\n{\n    class Program\n    {\n        public static void Main(string[] args)\n        {\n            WriteLine(\"hello\".Capitalize());    // and then you can use it\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabbalaci%2Fjabbacustomextensions-for-c-sharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjabbalaci%2Fjabbacustomextensions-for-c-sharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabbalaci%2Fjabbacustomextensions-for-c-sharp/lists"}