Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# create dynamic object

        // my pretend dataset
        List<string> fields = new List<string>();
        // my 'columns'
        fields.Add("this_thing");
        fields.Add("that_thing");
        fields.Add("the_other");

        dynamic exo = new System.Dynamic.ExpandoObject();

        foreach (string field in fields)
        {
            ((IDictionary<String, Object>)exo).Add(field, field + "_data");
        }

        // output - from Json.Net NuGet package
        textBox1.Text = Newtonsoft.Json.JsonConvert.SerializeObject(exo);
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# read binary file 
Csharp :: c# split on multiple characters 
Csharp :: c# compile code at runtime 
Csharp :: call stored proc c# 
Csharp :: unity create a child object 
Csharp :: convert json to list object c# 
Csharp :: c# byte array to bitmap 
Csharp :: c# datagridview search filter 
Csharp :: change sprite of a sprite unity 
Csharp :: add object to list c# 
Csharp :: jump in unity 
Csharp :: 2d topdown movement unity 
Csharp :: cast int to enum type c# 
Csharp :: how to check a list is null or empty in c# 
Csharp :: bytes to httppostedfilebase c# 
Csharp :: how to print using C# 
Csharp :: c# day of week number 
Csharp :: c# bytes to image 
Csharp :: c# get datatable column names to list 
Csharp :: c# read authorization header 
Csharp :: C# tolower all in a array 
Csharp :: unity pick random number 
Csharp :: c# underscore variable 
Csharp :: ngrok for https 
Csharp :: switch case in c# with multiple values 
Csharp :: how to check datagridview cell is null or empty 
Csharp :: wpf app how to get all elements which are exposed to script 
Csharp :: remove all non alphabetic characters from string c# 
Csharp :: c# return list in descending order 
Csharp :: relative path c# 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =