If it ran, that's because it was running a previous version (it should prompt you if there are errors if you want to run the old version). Errors mean it didn't build correctly; warnings mean it built but might be wrong.
In this case, the problem is scoping, that is, you're defining the variables within the scope of Accedptdetails, so the other functions, GetArea and Display, don't know about those variables. Scope is basically the { }. Something like this will give you more what you're thinking:
Code: using System;
namespace RectangleApplication
{
class Rectangle
{
// member variables
double length = 4.5;
double width = 3.5;
public void Acceptdetails()
{
}
public double GetArea()
{
return length * width;
}
public void Display()
{
Console.WriteLine("Length: {0}", length);
Console.WriteLine("Width: {0}", width);
Console.WriteLine("Area: {0}", GetArea());
}
}
class ExecuteRectangle
{
static void Main(string[] args)
{
Rectangle r = new Rectangle();
r.Acceptdetails();
r.Display();
Console.ReadLine();
}
}
}
So, remember, if you want a variable to be visible at a certain scope (i.e., within a certain set of {}), it needs to be defined in that scope or higher (i.e., within those {}, or within {} that those {} are contained).