Show / Hide Table of Contents

    IDataUnpacker.Keys Property

    .NET Standard 2.x

    Gets the keys of all of the elements in the IDataUnpacker object.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    string[] Keys { get; }
    

    Property Value

    System.String[]

    The keys of all of the elements in the IDataUnpacker object.

    Examples

    The folowing code example gets and displays the key of elements of dataUnPacker objects.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataUnpackerExamples
    {
        public class KeysExample
        {
            private readonly SchoolContext _context;
    
            public KeysExample(SchoolContext dataContext)
            {
                // Sets the data context.
                _context = dataContext;
            }
    
            public void Example()
            {
                var packer = new DataPacker();
    
                packer.AddValue("name", "Name1");
                packer.AddValue("address", "Address1");
    
                var json = packer.GetTextString(DataFormat.Json);
    
                // Specifies the data format to Json
                var dataUnPacker = new DataUnpacker(json, DataFormat.Json);
    
                // Gets the key of elements in dataUnPacker
                var keys = dataUnPacker.Keys;
    
                // Gets and shows the key value one by one
                String keyvalues = "";
                for (int i = 0; i < dataUnPacker.Count; i++)
                {
                    keyvalues += keys.GetValue(i).ToString() + ",";
                }
                Console.WriteLine("Key Values: {0}", keyvalues);
    
                /* This code example produces the following output:
                
                Key Values: name,address,
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon