Show / Hide Table of Contents

    IDataPacker.DataFormat Property

    .NET Standard 2.x

    Gets the format of the text specified when creating the IDataPacker object.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    DataFormat DataFormat { get; }
    

    Property Value

    SnapObjects.Data.DataFormat

    The format of the text specified when creating the IDataPacker object.

    It only supports the DataFormat.Json format so far.

    Examples

    The following code example gets the data format of DataPacker object.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataPackerExamples
    {
        public class DataFormatExample
        {
            private readonly SchoolContext _context;
    
            public DataFormatExample(SchoolContext dataContext)
            {
                // Sets the data context.
                _context = dataContext;
            }
            
            public void Example()
            {
                var packer = new DataPacker(DataFormat.Json);
    
                packer.AddValue("name", "Name1");
                packer.AddValue("Age", "30");
    
                // Gets and shows the number of elements
                Console.WriteLine("The element count: {0}", packer.Count);
                Console.WriteLine("DataFormat: {0}", packer.DataFormat);
    
                /* This code example produces the following output:
                
                The element count: 2
                DataFormat: Json
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon