Pregunta

I have a data object in php generated from a WSDL. One variable in this data object is named " KeyValuePairOfstringanyType" of type KeyValuePairOfstringanyType[]

great. How do I declare that and assign a value to it?

¿Fue útil?

Solución

It should just be a PHP array with a single key->value and use a string for the key:

$someDataObject->KeyValuePairOfstringanyType = array("somekey"=>"some value");

Otros consejos

C#

Assuming that you're creating a plugin (we're talking C# code, right)?

KeyValuePair<String, Object> general = new KeyValuePair<String, Object>();
KeyValuePair<String, Object> specific 
  = new KeyValuePair<String, Object>{ Key = "Konrad", Value = new Object() };
KeyValuePair<String, Object> typed 
  = new KeyValuePair<String, Object>{ Key = "Konrad", Value = "Viltersten" };

The first creates an empty instance. The other two have values. I put in the last one to exemplify that the Object instance can be pretty much anything. You're not locked to Object class.

Also, if you're going to have an array (a set, a bunch) of KeyValuePair instances, the suggested way is to use the following. The Dictionary instance consist of a number of such objects.

Dictionary<String, Objet> pairs = new Dictionary<String, Object>();
pairs.Add("key", new Object());

JS

Assuming that you're talking about UI (that's be JavaScript), there's no equivalence, as JS isn't really object oriented that way. You could do the following.

var kindOfKeyValuePair = "beep";
kindOfKeyValuePair.key = "myKey";
kindOfKeyValuePair.value = "myValue";

However, you might as well go like this too (which differs from the C# way where you're working with strongly typed, real programming language).

var kindOfKeyValuePair = "beep";
kindOfKeyValuePair.notKey = "myKey";
kindOfKeyValuePair.hardlyAnyValue = "myValue";

Other

Assuming that you wish to code PHP inside CRM, that's not going to happen (unless you're talking about filling an IFRAME component with an external content from a page powered by it).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top