Question: Write a C# program using a Linq statement. Create a string list. Use Console.ReadLine() to collect values of firstName, lastName, street, city, state, zip, save

Write a C# program using a Linq statement.

Create a string list.

Use Console.ReadLine() to collect values of firstName, lastName, street, city, state, zip, save them to List.

Write a simple Linq statement, then call method ***UppercaseWords() to change first letter to uppercase.

Create a foreach statement to display the information (foreach (var in )).

***Method uppercaseWords() is provided and needs to be included entirely in the program:

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);

}

_______________________________________________OUTPUT____________________________________________________

(Note: The following information is provided by the user.)

Enter first name: michael

Enter last name: johnson

Enter street: 999 first street

Enter city: seattle

Enter state: washington

Enter Sip code: 98433

(The following information is generated automatically. There are upper case letters at the beginning of every word.)

Costumers information:

Michael

Johnson

999 First Street

Seattle

Washington

98433

Press any key to continue... ______________________________________________________________________________________________________________________________

I have also included a similar sample code that can be used as a reference for this project:

// Fig. 9.7: LINQWithListCollection.cs

// LINQ to Objects using a List< string >. using System; using System.Linq; using System.Collections.Generic; public class LINQWithListCollection { public static void Main( string[] args ) { // populate a List of strings List< string > items = new List< string >(); items.Add( "aQua" ); // add "aQua" to the end of the List items.Add( "RusT" ); // add "RusT" to the end of the List items.Add( "yElLow" ); // add "yElLow" to the end of the List items.Add( "rEd" ); // add "rEd" to the end of the List // convert all strings to uppercase; select those starting with "R" var startsWithR = from item in items let uppercaseString = item.ToUpper() where uppercaseString.StartsWith( "R" ) orderby uppercaseString select uppercaseString; // display query results foreach ( var item in startsWithR ) Console.Write( "{0} ", item ); Console.WriteLine(); // output end of line items.Add( "rUbY" ); // add "rUbY" to the end of the List items.Add( "SaFfRon" ); // add "SaFfRon" to the end of the List // display updated query results foreach ( var item in startsWithR ) Console.Write( "{0} ", item ); Console.WriteLine(); // output end of line } // end Main } // end class LINQWithListCollection

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!