Skip to content

ExpandoObject

Coding Seb edited this page May 30, 2019 · 4 revisions

From version 1.2.2 ExpressionEvaluator manage ExpandObject class. ExpandoObject are object that can dynamically create new properties when you assign a value to it. It is also a dictionnary of properties. In ExpressionEvaluator you can use it as a object or as a dictionnary.

Here some examples :

myVar = new ExpandoObject();

myVar.X = 23.5;
myVar.Y = 34.8;

return myVar.X + myVar.Y;
// 58.3
myVar = new ExpandoObject();

myVar["Text"] = "Hello ";

return myVar["Text"] + " Bob" ;
// "Hello Bob"
myVar = new ExpandoObject();

myVar["Text"] = "Hello ";

return myVar.Text + " Bob" ;
// "Hello Bob"
myVar = new ExpandoObject();

myVar.Text = "Hello ";

return myVar["Text"] + " Bob" ;
// "Hello Bob"
obj = new ExpandoObject();

obj.Add = (x, y) => 
{
    text = "The result is : ";
    return text + (x+y).ToString();
};

return obj.Add(3, 4);
// "The result is : 7"

Anonymous Objects

And from version 1.3.7 ExpandoObject can be created as anonymous objects:

obj = new {
    Text = "Hello",
    IntValue = 8,
    Add = (x, y) =>
    {
        text = "The result is : ";
        return text + (x+y).ToString();
    }
};

Table Of Content

Clone this wiki locally
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy