How to convert lowercase characters from string to indexes start from 0 in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string s = "abcdvb";
        
        for (int i = 0; i < s.Length; i++) {
            int index = s[i] - 97;
            Console.WriteLine(index);
        }
    }
}



/*
run:

0
1
2
3
21
1

*/

 



answered Oct 23, 2020 by avibootz
...