Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 321917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:53:23+00:00 2026-05-12T08:53:23+00:00

I am new to C# and visual studio 2005 I created a new Console

  • 0

I am new to C# and visual studio 2005
I created a new Console Application project in VS2005 and added a Class1.cs file to the existing Program.cs file that was created by default.

The Class1.cs file has the following simple code:

public class Class1
{

    public Class1()
    { 
    }

    ~Class1()
    {
    }

    public void PrintMessage()
    {
        Console.WriteLine("\nHello\n");
        Console.Read();
    }
}

And program.cs file has the following:

class Program
{
    static void Main(string[] args)
    {
        PrintMessage();
    }
}

When I try to compile I get the following error:

The name ‘PrintMessage’ does not exist in the current context.

Any help?

Thanks, Viren

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:53:24+00:00Added an answer on May 12, 2026 at 8:53 am

    You need a reference to the class where the method is. You must do that with:

    Class1.PrintMessages();
    

    Since Class1 is not static, you also need an instance of that class. You could do that with:

    Class1 c = new Class1();
    

    Finally, you have to call the method prefixed with the instance variable. Your code will look something like this:

    Class1 c = new Class1();
    c.PrintMessages();
    

    If you want, you can shorten this code with the sentence

    new Class1().PrintMessages();
    

    that do the same as before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a new C++ project in Visual Studio 2008. No code has been
I'm working on a script that generates Visual Studio 2005 C++ project files (.vcproj).
I am new to visual studio/asp.net so please bear with me. Using vs 2005
Often times a developer on my team will create a new Visual Studio project
Background In Visual Studio 2008 Create a new Windows Forms Application, this will create
In Visual Studio, two files are created when you create a new Windows Form
I'm fairly new to Visual Studio and am wondering how best to plan for
For some reason when I create a new namespace in Visual Studio 2008 its
In Visual Studio 2008 add a new DataGridView to a form Edit Columns Add
Why does Visual Studio declare new classes as private in C#? I almost always

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.