Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ExpandoObject

Coding Seb edited this pageMay 30, 2019 ·4 revisions

From version 1.2.2 ExpressionEvaluator manageExpandObject 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=newExpandoObject();myVar.X=23.5;myVar.Y=34.8;returnmyVar.X+myVar.Y;// 58.3
myVar=newExpandoObject();myVar["Text"]="Hello ";returnmyVar["Text"]+" Bob";// "Hello Bob"
myVar=newExpandoObject();myVar["Text"]="Hello ";returnmyVar.Text+" Bob";// "Hello Bob"
myVar=newExpandoObject();myVar.Text="Hello ";returnmyVar["Text"]+" Bob";// "Hello Bob"
obj=newExpandoObject();obj.Add=(x,y)=>{text="The result is : ";returntext+(x+y).ToString();};returnobj.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 : ";returntext+(x+y).ToString();}};

Table Of Content

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp