Project Planning Question:
Download Questions PDF

Write the InStr function. Write the test cases for this function?


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InStr
class Program
static void Main(string[] args)
//test case 1, should return -1
string txt = "this is a test";
string searchString = "ae";
Console.WriteLine(InStr(txt, searchString));

//cast case 2, should return 2
txt = "this is a test";
searchString = "is";
Console.WriteLine(InStr(txt, searchString));


//return the position of the first occurrence of one
string "searchString" within another "txt"
//return -1 means cannot find
static int InStr(string txt, string searchString)
return txt.IndexOf(searchString);

Download Project Planning Interview Questions And Answers PDF

Previous QuestionNext Question
Suppose You have 3 jars. Each jar has a label on it: white, black, or white&black. You have 3 sets of marbles: white, black, and white&black. One set is stored in one jar. The labels on the jars are guaranteed to be incorrect (i.e. white will not contain white). Which jar would you choose from to give you the best chances of identifying the which set of marbles in is in which jar?Write a function that counts the number of primes in the range [1-N]. Write the test cases for this function?