How to extract the first three characters from a string into an array with C#

1 Answer

0 votes
using System;
using System.Linq;
 
class Program
{
   static void Main() {
        string s = "c#-programming";
         
        char[] array = s.Take(3).ToArray();
 
        Console.WriteLine(array);
        Console.WriteLine(s);
    }
}
 
 
 
 
/*
run:
 
c#-
c#-programming
 
*/

 



answered Jun 8, 2021 by avibootz

Related questions

...