IDataPacker.GetTextString(DataFormat format) Method
.NET Standard 2.x
Gets a string in the specified format which represents all elements in the current IDataPacker
object.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
string GetTextString(DataFormat format);
Parameters
format
SnapObjects.Data.DataFormat
The format of the text string you want to get.
It supports DataFormat.Json
and DataFormat.Xml
so far.
Returns
System.String
Returns the string of text in the specified format.
Examples
The following code example adds a value to the DataPacker
object and use GetTextString
method to get the specified format.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.IDataPackerExamples
{
public class GetTextStringExample
{
private readonly SchoolContext _context;
public GetTextStringExample(SchoolContext dataContext)
{
// Sets the data context.
_context = dataContext;
}
public void Example()
{
var packer = new DataPacker();
// Adds values to DataPacker.
packer.AddValue("Name", "Name1");
packer.AddValue("Age", "30");
// Gets and shows all of the data values in JSON format
Console.WriteLine(packer.GetTextString(DataFormat.Json));
/* This code example produces the following output:
{"Name":"Name1","Age":"30"}
*/
}
}
}
Applies to
.NET Standard
2.x