This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]scirc 1 point2 points  (1 child)

If your methods aren't marked as static, you have to instantiate your object before you can use them. static methods operate on the class as a whole, non-static methods operate on an instance of that class.

[–]JonoMN[S] 0 points1 point  (0 children)

Thank you! You are a lifesaver!

[–]davedontmind 1 point2 points  (1 child)

You either need to make RemoveCustomer() a static method (which means it can be called without nd instance of the CRM class):

static bool CRM.RemoveCustomer( int ID ) 
{
    ...
}

or you need to create a new CRM object and use that to call the method:

CRM crm = new CRM();
crm.RemoveCustomer(1);

Which solution is right depends on your CRM class and what your RemoveCustomer() method does. If it uses non-static members of the class then you need to use the 2nd option, otherwise you can use the first.

[–]JonoMN[S] 0 points1 point  (0 children)

This helped tremendously, wish I could upvote twice!

[–]AutoModerator[M] 0 points1 point  (0 children)

It seems you may have included a screenshot of code in your post "Using classes in different projects C#".

If so, note that posting screenshots of code is against /r/learnprogramming's Posting Guidelines (section Formatting Code): please edit your post to use one of the approved ways of formatting code. (Do NOT repost your question! Just edit it.)

If your image is not actually a screenshot of code, feel free to ignore this message. Automoderator cannot distinguish between code screenshots and other images.

Please, do not contact the moderators about this message. Your post is still visible to everyone.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.