How to copy a substring into char array in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "c# modern programming";

            char[] arr = new char[5];

            s.CopyTo(10, arr, 0, 5);
            Console.WriteLine(arr);
        }
    }
}


/*
run:
     
progr
 
*/

 



answered Dec 22, 2016 by avibootz

Related questions

1 answer 170 views
170 views asked Aug 15, 2022 by avibootz
1 answer 134 views
3 answers 314 views
314 views asked Mar 22, 2015 by avibootz
1 answer 181 views
1 answer 172 views
1 answer 167 views
2 answers 207 views
207 views asked Aug 15, 2022 by avibootz
...