C
csharpquestion
Hi all. I have a real simple question that is driving me nuts. I
have the a console app with 3 classess.
I am trying to access c2.doit() from Class1 - but I can't. I can only
access from the Program class. I am using
Visual Stuido 2005. It works in VS2003. What am I doing wrong?
Thanks
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Class2 c2 = new Class2();
// THIS WORKS
c2.doit();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Class1
{
// COMPILES WITH THE FOLLOWING LINE
Class2 c2 = new Class2();
// DOES NOT COMPILE - c2 CANNOT BE FOUND
c2.doit();
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
public class Class2
{
public void doit()
{
string f = "";
}
}
}
have the a console app with 3 classess.
I am trying to access c2.doit() from Class1 - but I can't. I can only
access from the Program class. I am using
Visual Stuido 2005. It works in VS2003. What am I doing wrong?
Thanks
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Class2 c2 = new Class2();
// THIS WORKS
c2.doit();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Class1
{
// COMPILES WITH THE FOLLOWING LINE
Class2 c2 = new Class2();
// DOES NOT COMPILE - c2 CANNOT BE FOUND
c2.doit();
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
public class Class2
{
public void doit()
{
string f = "";
}
}
}