0

i have one main class and with in this main class i have another class A. class A has few static property and when i tried to access those static property from outside but getting error....not being possible

here is my classes structure

 public class EShip
{
    class Credentials
    {
        private static string _accessKey = "aaa";
        private static string _accessPwd = "xxx";
        private static string _accountNumber = "2222";

        public static string AccessKey
        {
            get { return _accessKey; }
        }

        public static string AccessPassword
        {
            get { return _accessPwd; }
        }

        public static string AccountNumber
        {
            get { return _accountNumber; }
        }
    }

    public static Credentials Credential
    {
        { get; }
    }
}

i try to expose that inner class by a main class property and from outside i try to do like

EShip.Credentials.AccessKey
EShip.Credentials.AccessPassword

it is not getting possible......suggest me good approach and why i am stuck. thnx.

1
  • 3
    Please don't make us guess the error Commented Nov 9, 2012 at 13:13

1 Answer 1

2

Class Credentials is not public, therefore it's not accessible. Change that and you're able to do:

String key = EShip.Credentials.AccessKey;

Access Modifiers (C# Programming Guide)

Sign up to request clarification or add additional context in comments.

3 Comments

do i need to make the Credentials class public. due to security reason i do not want to do so.....any way out?
You could create a wrapperclass that displays the values that should be visible in public
You have made your property public anyway. Apart from that, why do you make it static? That means you have only one account in your program.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.