Question
use C# to slove project Name your class References.cs. Implement the following methods. Method name: ReadStudentNames Purpose: This method accepts an array of strings as
use C# to slove project
Name your class References.cs. Implement the following methods. Method name: ReadStudentNames Purpose: This method accepts an array of strings as a parameter. It loops through the array and asks user to input names. It populates the array of strings with the names. Parameters: an array of strings, stringArray Return type: void In the body of the method: Loop through the entire array o Prompt the user to enter a name o Read a name and assign it to the current element of the array. Use index i. 2. In the Main method and insert the following lines of code, Put in WriteLine showing a statement that you are going to pass a reference type by value Declare an array of strings as a local variable and call it nameArray. Allocate it a total of 5 elements. Call the ReadStudentNames method and pass nameArray by value as an argument. Loop through the entire nameArray o Print the value of the strings inside the array to the console.
Learning Points Note that arrays, which are reference-types do not need to be passed by reference to demonstrate behavior similar to what we saw when we passed a value-type by reference. Note how you are able to access the entire array of variables that are not declared within a given method if they are passed to that method. Consider the implications: if you pass a reference and that reference leads to other variables all those variables become full accessible. Passing value-types by reference OR passing reference-types by value results in similar behavior.
Sample Output file:///G:/CIS 345 Fall 2015/InClass/CIS345 Fall 2015 Inclass2 References/SpendingCalculator/bin/D... Passing a Reference Type By Ualue -Reading 5 Nanes* utting values inside stringArray parameter nter name 1Mark nter name 2: Matthew ter name 3: Erica ter name 4: Mary nter name 5: John The contents of nameArray are: Mark atthew rica Mary ohnStep 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