How to find the index of the last space in string with C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string s = "c# vb.net java c c++ python java";  
        char ch = ' ';
        
        int last_index = s.LastIndexOf(ch);  
           
        Console.WriteLine(last_index);  
    }
}




/*
run:

27

*/

 



answered Feb 16, 2022 by avibootz

Related questions

1 answer 86 views
1 answer 91 views
1 answer 78 views
1 answer 87 views
1 answer 83 views
...