How to get index before quotes in a string with C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string str = "c c# \"java\" python c++";
        
        int index_before_quotes = str.IndexOf("\"") - 1;
        
        Console.WriteLine(index_before_quotes);
    }
}
 
 
 
 
 
/*
run:
 
4
 
*/

 



answered Aug 19, 2023 by avibootz
...