Coder Social home page Coder Social logo

chalarangelo / 30-seconds-of-csharp Goto Github PK

View Code? Open in Web Editor NEW
180.0 13.0 36.0 324 KB

Short C# code snippets for all your development needs

Home Page: https://www.30secondsofcode.org/c-sharp/p/1/

License: Creative Commons Zero v1.0 Universal

C# 100.00%
snippets snippets-collection learning-resources learn-to-code programming education csharp

30-seconds-of-csharp's Introduction

Hi there ๐Ÿ‘‹

I'm Angelos Chalaris, a web developer from Athens, Greece. I love programming both as a job and as a hobby and I spend a lot of time writing code and testing out new ideas. I work mainly with web technologies such as JavaScript, HTML, CSS, Node.js, React and SCSS, and I occasionally dabble in Python, Astro and Svelte.

My work ๐Ÿ”ญ

Contact ๐Ÿ“ซ

You can reach me via email at [email protected]

30-seconds-of-csharp's People

Contributors

30secondsofcode avatar chalarangelo avatar trinityyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

30-seconds-of-csharp's Issues

Palindrome

Hi, i would like to add my PR
Returns true if the given string is a palindrome, false otherwise.

Generalize array/list snippets

Currently certain snippets can only apply to arrays or lists. However, Stringify showcases a generalized example for IEnumerable. We should investigate the following snippets for a generalized version:

  • Chunk
  • All
  • None
  • DistinctValues

Related milestone: 2020 Sprint 1

PadNumber and string interpolation

Description

The PadNumber snippet uses string interpolation to convert an integer to a string with leading zeroes to a specified length. I suggest using concatenation instead of interpolation.

Here is the current snippet:

public static string PadNumber(int n, int length)
{
    return n.ToString($"D{length}");
}

String interpolation adds overhead including extra memory use and extra CPU time. In this case, the interpolation doesn't help anything, so it's overhead with no benefit.

The method below uses a little less time and memory, and is slightly simpler because the user does not have to understand C# string interpolation. Obviously, the user will encounter string interpolation elsewhere but that should be when faced with a situation where interpolation is more useful.

public static string PadNumber(int n, int length)
{
    return n.ToString("D" + length.ToString());
}

There are ways to make this more performant, but that's not usually necessary when using a function like this.

Merge Type tag into Utility

Currently, both tags are quite empty. It is preferable to move all the Type snippets into Utility, at least for now.

Fix typos in snippet descriptions/explanations/examples

Most snippets currently use True and False in descriptions, explanations and examples instead of true and false (uppercase vs lowercase). This might confuse users. We should update all existing snippets to replace these typos with the correct form.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.