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

  • Home
  • SEARCH
  • 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 am using Visual Studio 2005. I created an MFC based console application named
I have a Visual Studio 2005 C++ project, it is a console application. I
I created a new Visual Studio Setup project with VS 2008. I use it
I'm working on a script that generates Visual Studio 2005 C++ project files (.vcproj).
i'll work in a new project using visual studio 2005, .net framework 3.5 and
I have an old Report Server Project created in Visual Studio 2005. The reports
I need to use Visual Studio 2005 (C++) on my new laptop - a
I'm completely new to Visual Studio and I'm having some trouble getting a project
I'm using Visual Studio 2005 for a project I'm working on right now. I've
I'm new to C# and using C#.Net 2.0 with Visual Studio 2005. How can

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.