C# Code Snippets

A collection of powerful and useful code snippets written in C# for .NET developers. Source code is submitted by Visual C# Kicks and website readers. We encourage you to submit your own code and rate other people's submittions.

 

All C# Code Snippets are under the Visual C# Kicks license agreement

 

Submit a Code Snippet

Delete Self
  • 4.56/5
Allows a standalone program to delete itself.

Shuffle Lists and Arrays
  • 3.94/5
An in-place algorithm to randomly shuffle a list or array in C#

C# Distance Formula
  • 3.77/5
A simple implementation of the distance formula in C#

Data to CSV
  • 3.65/5
Write a DataTable or a DataView to a CSV file

C# Fraction Structure
  • 3.65/5
A C# struct to represent decimal numbers as fractions.

C# Combination Function
  • 3.63/5
A simple function to calculate the number of possible combinations.

Degrees To Point and Back
  • 3.61/5
Convert an angle in degrees into an XY-coordinate point and back.

Temporary File C# Class
  • 3.57/5
Easily handle temporary file management in C#

Taking Screenshots with C#
  • 3.53/5
Using API calls in C# to capture an image of the monitor screen.

Multilevel Hierarchy - Class Interface
  • 3.5/5
An example of a multilevel hierarchy using class interfaces

Sort Strings by Length
  • 3.29/5
Sort a collection of strings by their length, from shortest to longest.

C# Encryption Class
  • 3.21/5
Class to easily encrypt strings and other types of data.

Linq Objects New
  • 3/5
Querying linq objects

RNGCryptoServiceProvider Random Integer
  • 2.87/5
Generate a random integer in a range using the RNGCryptoServiceProvider class.

C# Factorial
  • 2.63/5
Calculate the factorial value of a number in C#.NET

PHP Time
  • 2.56/5
Returns time represented in the same way as the PHP time() function.

Submit a Code Snippet

 

License Agreement | Privacy Policy
Link to Us | Subscribe to Newsletter | Contact Us