Show / Hide Table of Contents

    IDataPacker.Keys Property

    .NET Standard 2.x

    Gets the keys for the elements which have been added into the IDataPacker object.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    string[] Keys { get; }
    

    Returns

    System.String[]

    The keys for the elements which have been added into the IDataPacker object.

    Examples

    The following code example gets the key values one by one in the DataPacker object.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataPackerExamples
    {
        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("Age", "30");
    
                // Gets the keys of elements
                var keys = packer.Keys;
    
                // Gets and shows the key values one by one
                String keyvalues = "";
                for (int i = 0; i < packer.Count; i++)
                {
                    keyvalues += keys.GetValue(i).ToString() + ",";
                }
                Console.WriteLine("Key Values: {0}", keyvalues);
    
                /* This code example produces the following output:
                
                Key Values: Name,Age,
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon