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
Test the save dialog in Notepad?
How would you deal with a bug that no one wants to fix? Both the SDE and his lead have said they won?t fix it?
Given a MAKEFILE (yeah a makefile), design the data structure that a parser would create and then write code that iterates over that data structure executing commands if needed.
Explain dll hell?
Did you used crystal reports? Do you have sufficient knowledge on crystal reports?
funds flows analysis how to prepare for interview
Tell about current project ?
How do you rate yourself in c#,vb.net,Asp.net,oracle,sql server ?
Write a function that inserts an integer into a linked list in ascending order. Write the test cases for this function.
Why do you want to work for Microsoft?
Please, i am a final year student in nigeria and i have a project on pension fund administration and i need help in starting.
Write the instr function.
How do you ensure that your project plan is available for others to see? Where will you find the plans of other projects executed (in the past or currently) in the center?
how to tell project details in interview the project is funds flow analysis?
create a flow diagram up to 2 levels for hospital management