System.object[] value; String MyString; MyString = (String)value[0]; // or to get all the values in Value foreach(object obj in value) { (String)obj; }
במקרה הראשון אני מקבל את ההודעה הבאה: Cannot apply indexing with [] to an expression of type 'object' ובמקרה השני: foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'
במקרה הראשון: String[] MyString = (String[])value; ההודעה היא: Unable to cast object of type 'System.Object[]' to type 'System.String[]'. במקרה השני: string tty1 = (string)((string[])value)[0]; ההודעה היא: Unable to cast object of type 'System.Object[]' to type 'System.String[]'.
אולי זה יעזור....את ה object אני מקבל: private object GetAttributeValue(string key, DirectoryEntry userEntry) object value = userEntry.Properties[key].Value; ואז אני מנסה להוציא את הנתונים מתוך value ולא מצליח.