error:An object reference is required for the non-static field, method, or propert

jassie

Well-known member
Joined
Nov 13, 2012
Messages
61
Programming Experience
1-3
In a C# 2008 solution file, there are 4 project files that interact with each other. While I am in the project file called 'app1', I want to be able to obtain the values in another project file called 'samples'.
When I am in debug looking at the locals window, I can see the value I want to obtain is in the following location: samples.PackageMetadata.SubCustomerNumber.
However I am getting the error: An object reference is required for the non-static field, method, or property 'samples.PackageMetadata.SubCustomerNumber.get'.
Thus can you show me code and tell me what I need to do so that I can obtain the 'SubCustomerNumber' value I need for an error message?
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,150
Location
Sydney, Australia
Programming Experience
10+
You have to use an instance of the PackageMetadata class rather than the class itself. It's the same with any class. You can't get the Length of a String if you have no String object to get it from.
 

TinyTree

Member
Joined
Jan 23, 2013
Messages
8
Programming Experience
Beginner
static fields and so on used by class, others by object. I thought.
 
Top Bottom