如何从静态类C#中获取const?

时间:2017-06-10 15:41:25

标签: c# c#-4.0

我的静态课内有conts:

static class RestfulPaths {
    static string BASE_URL = "A";
    static string SYNC_CHECK = "A";
}

在另一个类中,我尝试将const作为:

RestfulPaths.BASE_URL

2 个答案:

答案 0 :(得分:0)

使您的课程及其属性也public,然后您将从其他课程中获取它们。

public static class RestfulPaths
        {

            public static string BASE_URL = "A";

            public static string SYNC_CHECK = "A";

        }

答案 1 :(得分:-1)

public static class RestfulPaths {
    public static string BASE_URL = "A";
    public static string SYNC_CHECK = "A";
}