Question
1. Create a string List. 2. Use Console.ReadLine() to collect values of firstName, lastName, street, city, state, zip, save them to List. 3. Write a
1. Create a string List.
2. Use Console.ReadLine() to collect values of firstName, lastName, street, city, state, zip, save them to List.
3. Write a simple Linq statement, call method UppercaseWords() to change first letter to uppercase.
4. Create a foreach statment to display the information.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public static string UppercaseWords(string value) { char[] array = value.ToCharArray(); if (array.Length >= 1) { if (char.IsLower(array[0])) { array[0] = char.ToUpper(array[0]); } } for (int i = 1; i < array.Length; i++) { if (array[i - 1] == ' ') { if (char.IsLower(array[i])) { array[i] = char.ToUpper(array[i]); } } } return new string(array); }
I have the correct code, but for some reason the input data is not displaying after it is run.
Here is my code:
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions;
public class Program { public static void Main(string[] args) { List
foreach (var item in items) { Console.WriteLine(UpperCaseMethod(item.ToLower())); }
} public static string UpperCaseMethod(string input) { if (String.IsNullOrEmpty(input)) throw new ArgumentException("ARGH!"); return input.First().ToString().ToUpper() + input.Substring(1); }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started