The TTRPG network
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
💡𝚂𝗆𝖺𝗋𝗍𝗆𝖺𝗇 𝙰𝗉𝗉𝗌📱@programming.dev to C Sharp@programming.devEnglish · 2 years ago

Fastest Way to Get the First N Characters of a String in C# - Code Maze

code-maze.com

external-link
message-square
2
link
fedilink
-9
external-link

Fastest Way to Get the First N Characters of a String in C# - Code Maze

code-maze.com

💡𝚂𝗆𝖺𝗋𝗍𝗆𝖺𝗇 𝙰𝗉𝗉𝗌📱@programming.dev to C Sharp@programming.devEnglish · 2 years ago
message-square
2
link
fedilink
In this article, we will perform benchmark tests to determine the fastest way to get the first N characters of a string in C#.
alert-triangle
You must log in or # to comment.
  • copygirl@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    8
    ·
    2 years ago

    This is potentially dangerous, as it encourages dealing with text as an array of chars. But graphemes in Unicode, which represent a single symbol in a writing system (such as “H”, “心”, or “💚”), can take up multiple chars in a string. The linked approaches only work if you can guarantee that your string only contains ASCII. See also: The Absolute Minimum Every Software Developer Must Know About Unicode in 2023 (Still No Excuses!)

    • 💡𝚂𝗆𝖺𝗋𝗍𝗆𝖺𝗇 𝙰𝗉𝗉𝗌📱@programming.devOP
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      2
      ·
      2 years ago

      Yes, good point - I’d forgotten about Unicode in this context.

C Sharp@programming.dev

csharp@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !csharp@programming.dev

A community about the C# programming language

Getting started

  • C# @ Wikipedia
  • A Tour of the C# Language
  • Learn C#

Useful resources

  • C# documentation
  • C# Language Reference
  • C# Programming Guide
  • C# Coding Conventions
  • .NET Framework Reference Source Code

IDEs and code editors

  • Visual Studio (Windows/Mac)
  • Rider (Windows/Mac/Linux)
  • Visual Studio Code (Windows/Mac/Linux)

Tools

  • Decompilers: ILSpy, dotPeek
  • Scratchpad: LINQPad
  • Online playground and IL viewer: SharpLab

Rules

  • Rule 1: Follow Lemmy rules
  • Rule 2: Be excellent to each other, no hostility towards users for any reason
  • Rule 3: No spam of tools/companies/advertisements

Related communities

  • c/dotnet
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 1 user / day
  • 1 user / week
  • 9 users / month
  • 145 users / 6 months
  • 2 local subscribers
  • 1.79K subscribers
  • 264 Posts
  • 219 Comments
  • Modlog
  • mods:
  • Ategon@programming.dev
  • nibblebit@programming.dev
  • Spyros@programming.dev
  • BE: 0.19.18
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org