{"id":15067900,"url":"https://github.com/wajid7511/delegateandevents","last_synced_at":"2026-02-28T10:04:27.678Z","repository":{"id":257149132,"uuid":"857452096","full_name":"wajid7511/DelegateAndEvents","owner":"wajid7511","description":"This repository demonstrates the use of delegates and events in C#. It includes practical examples showing how to declare and use delegates for callbacks and implement event-driven programming. Perfect for developers looking to understand these key concepts in C# and apply them in real-world scenarios.","archived":false,"fork":false,"pushed_at":"2024-09-14T18:06:25.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-14T06:34:41.507Z","etag":null,"topics":["c-sharp","console-app","delegates","events"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wajid7511.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-09-14T17:39:08.000Z","updated_at":"2024-09-14T18:06:29.000Z","dependencies_parsed_at":"2024-09-15T03:22:37.160Z","dependency_job_id":"61a40419-2982-4caf-95dd-6751df0ec1a3","html_url":"https://github.com/wajid7511/DelegateAndEvents","commit_stats":null,"previous_names":["wajid7511/delegateandevents"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wajid7511/DelegateAndEvents","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wajid7511%2FDelegateAndEvents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wajid7511%2FDelegateAndEvents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wajid7511%2FDelegateAndEvents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wajid7511%2FDelegateAndEvents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wajid7511","download_url":"https://codeload.github.com/wajid7511/DelegateAndEvents/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wajid7511%2FDelegateAndEvents/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006853,"owners_count":26084207,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","console-app","delegates","events"],"created_at":"2024-09-25T01:28:57.206Z","updated_at":"2025-10-11T10:38:15.289Z","avatar_url":"https://github.com/wajid7511.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DelegateAndEvents in C#\n\nThis repository showcases the use of **delegates** and **events** in C#. It includes practical examples to demonstrate their implementation and use cases. Delegates and events are core features of C# that enable event-driven programming and callback methods, making them essential for writing flexible, responsive applications.\n\n## Features\n\n- **Delegates**: Learn how to declare, instantiate, and use delegates.\n- **Events**: Understand how to declare events, subscribe to them, and handle event-driven behavior.\n- **Practical Examples**: Several scenarios show the implementation of delegates and events in real-world applications.\n\n## Project Structure\n\n- **Program.cs**: Contains examples of delegates and events, including:\n  - Using delegates to reference methods.\n  - Invoking delegates.\n  - Declaring and raising events.\n  - Subscribing to and handling events.\n\n## Getting Started\n\n### Prerequisites\n\n- .NET SDK (version 8.0 or later)\n- A basic understanding of C# programming\n\n### Running the Project\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/wajid7511/DelegateAndEvents.git\n  \n2. Navigate to the project directory:\n   ```bash\n   cd DelegateAndEvents\n   ```\n3. Run the application:\n   ```bash \n    dotnet run\n    ```\n  \nWhat Are Delegates?\nDelegates are a type-safe function pointer in C#. They are used to encapsulate methods and can be passed as parameters. Delegates are particularly useful for defining callback methods.\n\nExample:\n   ```bash \n    public delegate void MyDelegate(string message);\n    \n    public class MyClass\n    {\n        public static void PrintMessage(string message)\n        {\n            Console.WriteLine(message);\n        }\n    } \n    \n    MyDelegate del = new MyDelegate(MyClass.PrintMessage);\n    del(\"Hello from delegate!\");\n```\n\nWhat Are Events?\nEvents provide a way for a class to notify other classes when something of interest occurs. Events are built on delegates and are typically used in scenarios where a one-to-many relationship is required between publishers and subscribers.\n\nExample:\n   ```bash \n    public class Publisher\n    {\n        public event EventHandler? OnChange;\n    \n        public void Change()\n        {\n            OnChange?.Invoke(this, EventArgs.Empty);\n        }\n    }\n    \n    public class Subscriber\n    {\n        public void OnPublisherChange(object sender, EventArgs e)\n        {\n            Console.WriteLine(\"Event triggered\");\n        }\n    }\n\n// Usage\nPublisher publisher = new Publisher();\nSubscriber subscriber = new Subscriber();\npublisher.OnChange += subscriber.OnPublisherChange;\npublisher.Change();\n```\n\nContributing\nFeel free to fork the repository and submit pull requests if you would like to contribute or suggest improvements.\n ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwajid7511%2Fdelegateandevents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwajid7511%2Fdelegateandevents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwajid7511%2Fdelegateandevents/lists"}