Write the InStr function. Write the test cases for this
function?
Answer Posted / echo
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));
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);
}
}
}
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
How do you rate yourself in c#,vb.net,Asp.net,oracle,sql server ?
How do you create the Software Project Management Plan (SPMP)?
Write a function that inserts an integer into a linked list in ascending order. Write the test cases for this function.
Did you used crystal reports? Do you have sufficient knowledge on crystal reports?
how to tell project details in interview the project is funds flow analysis?
Explain the various activities you do (as a PL) when the project is started up.
How did you choose the appropriate lifecycle for your project?
I want question and paper based MS Projects. Also is there any exam which microsoft conduct for Ms Project professional to issue certification?
What is the role of CLR in ASP.NET?
What and where are the policy statements for software project planning?
What training have you undergone in project planning?
Write the instr function.
Write the test cases for instr function?
Tell about yourself and job ?
Can any one please give me an effective format for designing a functional specification and technical specification sheet for a software developemnt related company asap...it would be highly useful for my final year project.