help needed regarding a c# program

Posted by Archit under C# on 9/11/2011 | Points: 10 | Views : 837 | Status : [Member] | Replies : 1
I have been studying c# via a fundamental book.
this is the program that i am trying to run but it gives error. I picked up this code from the book it self.
please try me how to correct these errors

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
static double readValue ( string prompt, double low, double high )
{
double result = 0;
do
{
Console.WriteLine (prompt + " between " + low + " and " + high );
string resultString = Console.ReadLine ();
result = double.Parse(resultString);
}
while ( (result < low) || (result > high) );
return result ;
}
}
}
}



Error 1 } expected
Error 2 Type or namespace definition, or end-of-file expected




Responses

Posted by: Rickeybglr on: 9/12/2011 [Member] Starter | Points: 25

Up
0
Down
u gettn ths eror bcoz od miss place of braces, try ths:
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
// call readvalue method frm here by creating class object (obj.readvalue(argu_list))
}

static double readValue ( string prompt, double low, double high )
{
double result = 0;
do

Console.WriteLine (prompt + " between " + low + " and " + high );
string resultString = Console.ReadLine ();
result = double.Parse(resultString);
}
while ( (result < low) || (result > high) );
return result ;
}
}
}


Archit, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response