Write the InStr function. Write the test cases for this function?
Submitted by: Administratorusing 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));
Console.Read();
}
//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);
}
}
}
Submitted by: Administrator
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));
Console.Read();
}
//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);
}
}
}
Submitted by: Administrator
Read Online Project Planning Job Interview Questions And Answers
Top Project Planning Questions
| ☺ | Write the test cases for a vending machine? |
| ☺ | what are all the test scenarios for login passwords?(user authentication)? |
| ☺ | What is the basics of Agile/Scrum development? |
| ☺ | How to estimate the cost of projects? |
Top Software System Design Categories
| ☺ | Technical Writer Interview Questions. |
| ☺ | Requirements Management Interview Questions. |
| ☺ | Project Planning Interview Questions. |
| ☺ | Design Patterns Interview Questions. |
| ☺ | Software Design Tools Interview Questions. |
