Question: here is the question C# cengage mindtap Write a program named InputMethodDemo2 that eliminates the repetitive code in the InputMethod() in the InputMethodDemo program in
here is the question C# cengage mindtap
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"); (Note: The program in Figure 8-5 is provided as starter code.)

here is my code it says its wrong
using System;
class InputMethodDemo2
{
static void Main()
{
int first, second;
InputMethod(out first, out second);
WriteLine("After InputMethod first is {0} and second is {1}," first,second);
}
private static void InputMethod(out int one, out int two)
{
one = DataEntry("first");
two = DataEntry ("second");
}
public static int DataEntry(string mystring)
{
returncovert.ToInt32 (ReadLine());
}
}
using System; using static System.Console; class Input MethodDemo Notice the { keyword out. static void Main() { int first, second; Input Method (out first, out second); WriteLine("After InputMethod first is {0}", first); WriteLine("and second is {0}", second); } private static void InputMethod(out int one, out int two) { string si, s2; Write("Enter first integer "); sl = ReadLine(); Notice the Write("Enter second integer "); keyword out. s2 = ReadLine(); one = Convert.ToInt32 (s1); two = Convert.ToInt32(s2); } } Figure 8-5 The InputMethodDemo program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
