Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 访问其他用户';具有自定义类型(类)的自定义配置文件属性_C#_Asp.net_Profile - Fatal编程技术网

C# 访问其他用户';具有自定义类型(类)的自定义配置文件属性

C# 访问其他用户';具有自定义类型(类)的自定义配置文件属性,c#,asp.net,profile,C#,Asp.net,Profile,我正在使用ASP.net和C#,试图从web.config文件访问另一个用户的Profile属性 我要访问的属性具有我创建的类的自定义类型,ClassesList: public class ClassesList { public struct Class_ { public string name; public string teacherName; public string startDate, endDate;

我正在使用ASP.net和C#,试图从
web.config
文件访问另一个用户的
Profile
属性

我要访问的属性具有我创建的类的自定义类型,
ClassesList

public class ClassesList
{
    public struct Class_
    {
        public string name;
        public string teacherName;
        public string startDate, endDate;
        public int numOfEnrolledStudents;
        public int maxNumOfStudents;
        public string[] studentsNames;
        public string accessKey;
        public bool IsActive;
     }

     public Class_[] Classes;

     public ClassesList()
     {
        this.Classes = new Class_[200];

        for (int i = 0; i < 200; i++)
        {
            Classes[i].IsActive = false;
            Classes[i].studentsNames = new string[500];
        }
     }
}
我使用此语句获取另一个用户的配置文件(在for循环中)

现在我有了配置文件,我只需要访问我想要的配置文件属性,即
accessKey

我试图使用此代码获取属性,但我得到了not found异常

currentTeacherProfile.GetPropertyValue("ClassList.Classes[0].accessKey")
注意:使用访问当前用户的配置文件属性

Profile.ClassList.Classes[0].accessKey
工作,但它不工作的情况下,不同的用户


谢谢。

您需要先获取属性值(ClassesList)

ProfileCommon otherProfile = Profile.getProfile("name");
然后,您可以访问该对象的属性

classList.Classes[0].accessKey
ProfileCommon otherProfile = Profile.getProfile("name");
ClassesList classList = currentTeacherProfile.GetPropertyValue("ClassList") as ClassesList;
classList.Classes[0].accessKey