Re: my first class - getting an error
- From: Registered User <n4jvp@xxxxxxxxxxxxx>
- Date: Mon, 10 Sep 2007 20:44:18 -0400
On Mon, 10 Sep 2007 16:36:21 -0700, vinnie <centro.gamma@xxxxxxxxx>
wrote:
I did my first project with the classes, but i get an error that iHere an instance of type Program is created.
don't understand, and so don't know how to correct it.
The error is :
"Error 1 'mixed_class.Program' does not contain a definition for
'Calculus' and no extension method 'Calculus' accepting a first
argument of type 'mixed_class.Program' could be found (are you missing
a using directive or an assembly reference?) C:\Documents and Settings
\Robert\Desktop\prova VS8\mixed_class\Program.cs 20 20 mixed_class"
This is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace mixed_class
{
public class Program
{
public static void Main(string[] args)
{
double c = 0;
Console.WriteLine(" Program for calculating the sum");
Console.WriteLine();
Console.WriteLine(" Insert first value:...");
double a = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(" Insert the second value:... ");
double b = Convert.ToDouble(Console.ReadLine());
Program So = new Program();This won't work because the Program class does not have a Calculus
method. The previous line should apparently instantiate an instance of
the summing class.
c = So.Calculus(3, 4);The return value and the out parameter of method are unneeded
Console.WriteLine(" The sum is: {0}", c);
Console.ReadLine();
}
}
public class summing
{
public double Calculus(double a, double b, out double c)
{
c = a + b;
return c;
}
duplicates. This function's signature matches the call to Calculate in
the Program cless' main function.
public double Calculus(double a, double b)
{
double c = a + b;
return c;
}
}regards
}
A.G.
.
- References:
- my first class - getting an error
- From: vinnie
- my first class - getting an error
- Prev by Date: Re: Blitting
- Next by Date: Re: my first class - getting an error
- Previous by thread: Re: my first class - getting an error
- Next by thread: need help with string format
- Index(es):