Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
find the index of the substring "fir" - Seeni
//Rextester.Program.Main is the entry point for your code. Don't change it. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354) using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { private static int IndexOf(string str, string substr) { bool match; for (int i = 0; i < str.Length - substr.Length + 1; ++i) { match = true; for (int j = 0; j < substr.Length; ++j) { if (str[i + j] != substr[j]) { match = false; break; } } if (match) return i; } return -1; } public static void Main(string[] args) { //How to find the first index of a substring in a given string? //use question as given string and find the index of the substring "fir". //Builin array functions and LINQ are not allowed. Console.WriteLine("Start here..."); string str = "How to find the first index of a substring in a given string?"; string substr = "fir"; int index = IndexOf(str, substr); Console.WriteLine(index); Console.ReadLine(); } } }
run
|
edit
|
history
|
help
0
Puzz1
6. Parallelism: threads
lilnq 1
The abstract factory design pattern implemented in c# using generics.
Day1
Constructor inheriterance
https://www.compliantmechanisms.byu.edu/profile/new-free-robux-generator-2022/profile
Program A
Print 1 to 100 without using loop
using int.TryParse