How to get the second character from each string of string array in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string[] arr = {"c#", "c++", "java", "php", "vb"};

        foreach (string s in arr) {
            if (!string.IsNullOrEmpty(s)) {
                Console.WriteLine(s[1]);
            }
        }
    }
}


/*
run:

#
+
a
h
b

*/

 



answered Nov 1, 2019 by avibootz

Related questions

1 answer 169 views
1 answer 150 views
1 answer 153 views
1 answer 106 views
1 answer 148 views
1 answer 169 views
...