C# code examples · runnable

20 runnable C# code examples.

Open any C# example to explore the code and run it online. No setup, no signup.

C#

How to loop through an enum in C#How to convert an int to an enum in C#How to check if a string contains a substring in C#How to iterate over a dictionary in C#How to deep clone an object in C#How to catch multiple exceptions in C#How to generate a random number in a range in C#How to calculate the difference between two dates in C#How to check for null in C#How to sort a list of objects by property in C#How to convert a byte array to a hex string in C#How to convert a string to a byte array in C#How to convert a string to an enum in C#How to remove duplicates from a list in C#How to loop with an index in C#How to group by with LINQ in C#How to convert an object to JSON in C#How to parse JSON into an object in C#How to convert a string to an int in C#How to join a list into a string in C#
Questions & answers

C# examples, explained

Can I run these C# code examples?

Yes. Open any C# example to edit and run its code on the CompileBytes engine without installing anything.

Is this free? Do I need an account?

Every example is free to read, run, edit, and copy. No account is required.

Can I copy these into my own projects?

Yes. These examples are designed to be copied and adapted to your own code.

Where can I run my own code?

Open the C# compiler from the main playground catalog, then paste or write any code you want to run.