Sum of the alphabetical values of the characters of a string | C # implementation of the approach ; Function to find string score ; Driver code
using System ; class GFG { static int strScore ( String [ ] str , String s , int n ) { int score = 0 , index = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == s ) { for ( int j = 0 ; j < s . Length ; j ++ ) score += s [ j ] - ' a ' + 1 ; index = i + 1 ; break ; } } score = score * index ; return score ; } public static void Main ( String [ ] args ) { String [ ] str = { " sahil " , " shashanak " , " sanjit " , " abhinav " , " mohit " } ; String s = " abhinav " ; int n = str . Length ; int score = strScore ( str , s , n ) ; Console . Write ( score ) ; } }