There's a few ways you can go about this. The first way is to make your fields publicly accessible. Right now you have them as private.
If it's intentional and desired for those fields to be private, you can make public properties for those fields so that you can control the access level. Here is an example of a struct with a property.
- public class Person
-
{
-
private string m_name;
-
-
public string Name
-
{
-
get { return m_name; }
-
set { m_name = value; }
-
}
-
// The rest of your class follows...
-
}
NOTE: You can include only the access that you want. If it's intended to be read only, don't include a set on the property definition. Also note that you can use properties on classes as well as structs.
The final way you can go about this, and something you might want to do anyway, is to override the ToString method on your struct. The ToString method is a part of the object class, something that every class in C# inherits from. Simply put the following code in your class...
- public override ToString()
-
{
-
return "string value";
-
}
The return value can be anything you like... so you could return the values of the variables. Then you can output the bus stop using Console.WriteLine, or directly call the ToString method to get the string value of it.
I hope that makes sense, let me know if you have any questions :)