C# interfaces ๐
Bro Code
@brocodezAbout
Coding bootcamps HATE HIM! ๐ฟ
Latest Posts
Video Description
C# interfaces tutorial example explained #C# #interfaces #interface using System; namespace MyFirstProgram { class Program { static void Main(string[] args) { // interface = defines a "contract" that all the classes inheriting from should follow // An interface declares "what a class should have" // An inheriting class defines "how it should do it" // benefits = security + multiple inheritance + "plug-and-play" Rabbit rabbit = new Rabbit(); Hawk hawk = new Hawk(); Fish fish = new Fish(); rabbit.Flee(); hawk.Hunt(); fish.Flee(); fish.Hunt(); Console.ReadKey(); } interface IPrey { void Flee(); } interface IPredator { void Hunt(); } class Rabbit : IPrey { public void Flee() { Console.WriteLine("The rabbit runs away!"); } } class Hawk : IPredator { public void Hunt() { Console.WriteLine("The hawk is searching for food!"); } } class Fish : IPrey, IPredator { public void Flee() { Console.WriteLine("The fish swims away!"); } public void Hunt() { Console.WriteLine("The fish is searching for smaller fish!"); } } } }
You May Also Like
Upgrade Your Gaming Setup Today
AI-recommended products based on this video

95MM T129215SU Cooling Fan for ASUS ROG Strix for GeForce RTX 3060 3070 3080 3090 Ti Graphics Card CF1010U12S/D T129215BU(Black A-Fan T12)

ASUS ROG Strix G16 Gaming Laptop, GeForce RTX 5070 Ti 12GB GDDR7, AMD Ryzen 9 8940HX, 64GB DDR5, 2TB SSD, Backlit Keyboard, Wi-Fi 6E, 16" WUXGA 165Hz Display, Win 11, Gray, 1TB Docking Station Set

ASUS ROG Strix G16 (2024) Gaming Laptop, 16โ 16:10 FHD+ 165Hz, GeForce RTX 4060, Intel Core i7-13650HX, 16GB DDR5, 1TB PCIe SSD, Wi-Fi 6E, Windows 11, G614JV-AS71-CA

Asus ROG STRIX Z890-A GAMING WIFI Z890 LGA 1851 ATX motherboard, Intelยฎ Coreโข Ultra Series 2 Ready, Advanced AI PC-ready, 16+2+1+2 stages, DDR5, WiFi 7, 2.5G, 5x M.2, Thunderboltโข 4, USB Type-C, AI OC

230W Charger Compatible with Razer Blade 14โ 15โ 16" 17โ (2025-2018) RZ09 RTX-3060/3070/3080/4060/4070 Gaming Laptop RC30-0530 RC30-0238 RC30-0248 Replacement Power Adapter

Logitech G502 Hero High Performance Wired Gaming Mouse, Hero 25K Sensor, 25,600 DPI, RGB, Adjustable Weights, 11 Programmable Buttons, On-Board Memory, PC/Mac, Black

New SteelSeries Arctis Nova Pro for Xbox Multi-System Gaming Headset - Premium Hi-Fi Drivers - Hi-Res Audio - 360ยฐ Spatial - GameDAC Gen 2 - Quad-DAC - ClearCast Gen 2 Mic - Xbox, PC, PS5/PS4, Switch

NEW SteelSeries Arctis Nova 3 Multi-Platform Gaming Headset - Signature Arctis Sound - ClearCast Gen 2 Mic - PC, PS5/PS4, Xbox Series X|S, Switch, Mobile

CORSAIR iCUE Link XD5 RGB Elite LCD Pump-Reservoir Unit - D5 PWM Pump - 480x480 IPS LCD Screen - 22 Addressable RGB LEDs - 440ml Nylon Reservoir - White

CORSAIR iCUE Link XC7 RGB Elite CPU Water Block - Transparent Flow Chamber - 24 RGB LEDs - Fits Intelยฎ LGA 1700, AMDยฎ AM5 and Older - White

CORSAIR Hydro X Series iCUE Link XH405i Custom Cooling Kit โ Hardline Water Cooling Loop โ XC7 Elite CPU Water Block โ XD5 Elite D5 Pump Res โ XR5 360mm Radiator โ 3X QX120 RGB Fans

Western Digital 2TB WD Blue SA510 SATA Internal Solid State Drive SSD - SATA III 6 Gb/s, 2.5"/7mm, Up to 560 MB/s - WDS200T3B0A

Corsair RM1000e Fully Modular Low-Noise ATX Power Supply - Dual EPS12V Connectors - 105ยฐC-Rated Capacitors - 80 Plus Gold Efficiency - Modern Standby Support - Black

Corsair RM1200x Shift Fully Modular ATX Power Supply - Modular Side Interface - ATX 3.1 & PCIe 5.1 Compliant - Zero RPM Fan Mode - 105ยฐC-Rated Capacitors - 80 Plus Gold Efficiency - Black, 1200W

Corsair RM1200e (2023) Fully Modular Low-Noise ATX Power Supply with 12V-2x6 Cable โ ATX 3.1 & PCIe 5.1 Compliant, Cybenetics Platinum Efficiency, 105ยฐC-Rated Capacitors, Modern Standby Mode โ Black

Corsair HX1200i (2025) Fully Modular Ultra-Low Noise ATX Power Supply with 12V-2x6 Cable โ ATX 3.1 & PCIe 5.1 Compliant, Cybenetics Platinum Efficiency, Fluid Dynamic Bearing Fan โ Black

Logitech K250 Bluetooth Keyboard with Numpad, Easy Connectivity, Compact Wireless Keyboard Made with Recycled Plastic, Spill-Resistant, Comfortable Keys - Windows/MacOS - Graphite




















