Starting out with Visual C# (4th Edition)
4th Edition
ISBN: 9780134382609
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 8.2, Problem 8.10CP
Explanation of Solution
IndexOf method:
Index of the specified string is used to find the position of the substring.
- IndexOf method is used to find the index of a string.
- IndexOf method returns the first occurrence of the specified char in a string.
- If the substring that is given as an argument is found in the string, it returns the integer position of the substring’s first occurrence and if it is not found in the string, the method returns “-1”.
Example:
//assign the value to variable
string str= “Hello world”;
//Find the position of the given argument
int position= str.IndexOf(“to”);
//display the output
MessageBox.Show(position.ToString());
Explanation:
- Declare and assign the value to the variable.
- Find the position of the given substring in the string.
- Display the result in the form of message box and as the substring was not found, it displays “-1”...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Implement the "Remove song" function. Prompt the user for the unique ID of the song to be removed.Ex:
REMOVE SONG
Enter song's unique ID: JJ234
"All For You" removed
This solution does not work for the question asked. The question submitted clearly shows 2 list boxes on form 1. Is there an updated code?
What does the Contains method return when the string does not contain the subString?
Chapter 8 Solutions
Starting out with Visual C# (4th Edition)
Ch. 8.2 - Declare a char variable named letter and assign...Ch. 8.2 - Prob. 8.2CPCh. 8.2 - Prob. 8.3CPCh. 8.2 - Write a foreach loop that displays each character...Ch. 8.2 - Write the first line of an if statement that calls...Ch. 8.2 - Write the first line of an if statement that calls...Ch. 8.2 - Write a statement that calls the char.ToUpper...Ch. 8.2 - Prob. 8.8CPCh. 8.2 - Prob. 8.9CPCh. 8.2 - Prob. 8.10CP
Ch. 8.2 - Prob. 8.11CPCh. 8.2 - A program has two string variables named vegetable...Ch. 8.2 - Prob. 8.13CPCh. 8.2 - What delimiter is used to separate data in a...Ch. 8.3 - Prob. 8.15CPCh. 8.3 - Prob. 8.16CPCh. 8.3 - Prob. 8.17CPCh. 8.3 - Prob. 8.18CPCh. 8.3 - Prob. 8.19CPCh. 8.3 - Suppose an application contains a structure named...Ch. 8.3 - Prob. 8.21CPCh. 8.3 - Prob. 8.22CPCh. 8.4 - Look at the following declaration: enum Flower {...Ch. 8.4 - Prob. 8.24CPCh. 8.4 - Prob. 8.25CPCh. 8.5 - Prob. 8.26CPCh. 8.5 - Prob. 8.27CPCh. 8.5 - Prob. 8.28CPCh. 8.5 - Prob. 8.29CPCh. 8.5 - Prob. 8.30CPCh. 8 - In C#, __________ are enclosed in single quotation...Ch. 8 - Prob. 2MCCh. 8 - Prob. 3MCCh. 8 - Prob. 4MCCh. 8 - Prob. 5MCCh. 8 - Prob. 6MCCh. 8 - __________ are spaces that appear at the beginning...Ch. 8 - Prob. 8MCCh. 8 - Prob. 9MCCh. 8 - Prob. 10MCCh. 8 - Prob. 11MCCh. 8 - The __________ file format is commonly used to...Ch. 8 - A __________ is a data type you can create that...Ch. 8 - Prob. 14MCCh. 8 - Prob. 15MCCh. 8 - When you create a(n) __________, you specify a set...Ch. 8 - Prob. 17MCCh. 8 - Prob. 18MCCh. 8 - Prob. 1TFCh. 8 - Prob. 2TFCh. 8 - Prob. 3TFCh. 8 - Prob. 4TFCh. 8 - Prob. 5TFCh. 8 - Structure objects can be passed into a method only...Ch. 8 - Prob. 7TFCh. 8 - Prob. 8TFCh. 8 - An enum declaration can only appear inside the...Ch. 8 - The integer values that you assign to enumerators...Ch. 8 - You can compare enumerators and enum variables...Ch. 8 - Prob. 12TFCh. 8 - What method can be used to convert a char variable...Ch. 8 - List the method you would use to determine whether...Ch. 8 - Prob. 3SACh. 8 - Briefly describe each of the following string...Ch. 8 - Prob. 5SACh. 8 - Prob. 6SACh. 8 - Assume an application contains a structure named...Ch. 8 - Can enumerators be used in a loop to step through...Ch. 8 - Prob. 9SACh. 8 - Prob. 10SACh. 8 - Prob. 1AWCh. 8 - Prob. 2AWCh. 8 - Look at the following structure declaration:...Ch. 8 - Declare an enumerated data type named Direction...Ch. 8 - Prob. 5AWCh. 8 - Prob. 1PPCh. 8 - Prob. 2PPCh. 8 - Sentence Capitalizer Create an application with a...Ch. 8 - Vowels and Consonants Create an application with a...Ch. 8 - Prob. 5PPCh. 8 - Prob. 6PPCh. 8 - Prob. 7PPCh. 8 - Prob. 8PPCh. 8 - Alphabetic Telephone Number Translator Many...Ch. 8 - Prob. 10PPCh. 8 - Drink Vending Machine Simulator Create an...Ch. 8 - Prob. 12PP
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- keys = ['name', 'last', 'job_title', 'email']Faculty2 = Faculty = dict.fromkeys(keys)print(Faculty2) Use the dictionaries that you created for faculty members. Be sure that all the dictionaries have the same keys: name, last name, etc. If there are keys or values missing, add them. If you do not have the value, you can use 'n/a' or 'TBD'. Make a list of the dictionaries. Loop the list to print all the information available to each faculty member. In Python lang please.arrow_forwardsearchStudent: searches the studentsList by idNum, passed as parameter. If the object is found, it returns its location in the studentsList, else returns -1.arrow_forwardHomework Instructions: For each Exercise below, write your code in an IDE and run your code within the IDE as well. Once you have satisfied the Exercise requirements, paste your code below under the corresponding Exercise. Exercise 1: Dogs mature at a faster rate than human beings. If you own a dog, you might've heard this rule: one year for Snoopy equals seven years for you. Turns out, the math isn't that simple. Dogs mature more quickly than we do early on. Here's how we can convert your dog's age into human years. The first two years of a dog's life count as 21 human years. ● Each following year counts as 4 human years. So, a one-year-old dog is 10.5 years old in human years, and a two-year-old dog is 21 years old in human years. How to write a C++ program called dog_years.cpp to calculate the age, in human years, of any dog older than 2. Exercise 2: The Pythagorean Theorem states that the hypotenuse (c) is the sum of the squares of the other two sides (a and b). This can be written…arrow_forward
- 10-13. Verify User: The final listing for remember_me.py assumes either that the user has already entered their username or that the program is running for the first time. We should modify it in case the current user is not the person who last used the program. Before printing a welcome back message in greet_user(), ask the user if this is the correct username. If it’s not, call get_new_username() to get the correct username.arrow_forwardYour program has a list of professors and their office location and office hours per day of the week. The user will type either a professor’s name or day of the week. If they type a professor’s name, show that professor’s office location and office hours (all days of the week). You don’t have to do a name search, you can require the user type the professor’s name exactly right. If the user types a day of the week, show all professors and office location for professors that have office hours on that day of the week. You don’t really need to use time/date code like we did for the notebook, you can just match the day of week by the word (String) e.g., your data has “Wednesday” so if a user types exactly “Wednesday” it matches. This can all be done with hash maps (and loops / if’s / etc.) using Javaarrow_forwardindividual characters using their 0-based index. Hint: You will need to do this for checking all the rules. However, when you access a character .arrow_forward
- A c++ code that performs a search for a specific employee and returns the employee ID if found and 0 if not: int findEmployeeById(Employee list[], int size, int myId)arrow_forwardWrite a procedure named DumpMemory that encapsulates the DumpMem procedure in theIrvine32 library. Use declared parameters and the USES directive. The following is anexample of how it should be called: INVOKE DumpMemory, OFFSET array, LENGTHOFarray, TYPE arrayarrow_forwardWhat does the operator delete do?arrow_forward
- Q 7 and 9 Please explain your answersarrow_forwardWrite a procedure called check_workday(check_day). The procedure should accept a single word as a parameter. You have been given a list called work_days. The list contains a couple of days that are defined as workdays for this problem. You are required to: check to see if the day passed to the procedure is a workday. If it is a workday print The name of the day, with the following statement on the same line: " is a workday" (see the example outputs) When the day is a Sunday, display the following statement on the next line: "The fee is double because it is Sunday." NB: Only write the procedure. Do not call it. Please refer to the examples below for further clarity. For example: Test Result check_workday("Monday") Monday is a workday check_workday("Sunday") Sunday is a workday The fee is double because it is Sunday. check_workday("Thursday") Thursday is a workdayarrow_forwardWhich of the following techniques can you use to load items into a drop-down list? Use the Add method of the list item collection to add an item with the specified Text property at the end of the collection Use the Add method of the list item collection to add an item with the specified Value property at the end of the collection Use the Add method of the list item collection to add an item with the specified Text and Value properties at the end of the collection Use the Add method with an index argument to add an item with the specified Text at the index location in the collectionarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,