Question: What I need: In C#, Write a program named InputMethodDemo2 that eliminates the repetitive code in the InputMethod() in the InputMethodDemo program in Figure 8-5.
What I need:
In C#,
Write a program named InputMethodDemo2 that eliminates the repetitive code in the InputMethod() in the InputMethodDemo program in Figure 8-5.
Rewrite the program so the InputMethod() contains only two statements:
one = DataEntry("first"); two = DataEntry("second"); What I have:
using System; namespace InputMethodDemo2 { class InputMethodDemo2 { static void Main() { //Variables for user input int first, second; //CAll method to get 2 integers from user by reference variables InputMethod(out first, out second); //Display result Console.WriteLine("After InputMethod first is {0} and second is {1}", first,second); } //Method to get input integers private static void InputMethod(out int one, out int two) { one = DataEntry("first"); two = DataEntry("second"); } //Method prompt for integer and return value public static int DataEntry(string myString) { Console.Write("Enter "+myString+" integer "); return Convert.ToInt32(Console.ReadLine()); } } }
Error I get:
Compilation failed: 1 error(s), 0 warnings NtTestba841086.cs(21,47): error CS0234: The type or namespace name `DataEntry' does not exist in the namespace `InputMethodDemo2'. Are you missing an assembly reference?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
