PrestwoodBoards Knowledgebase:

C# Code Snippet:
C# Substring

C# Substring

Above returns "abcd" on a string literal. You can, of course, use VarName.Substring(0, 4).

Console.WriteLine("abcdefgh".Substring(0, 4));
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile
Copyright (C) Prestwood IT Solutions.
All Rights Reserved.
Printed 7/14/2020