Click or drag to resize
ZenophSMSgetVariables Method (String)
Gets a list of variables defined in a message for personalisation.

Namespace: Zenoph.SMSLib
Assembly: Zenoph.SMSLib (in Zenoph.SMSLib.dll) Version: 2015.9.30.0 (2015.09.30.0)
Syntax
public static List<string> getVariables(
	string message
)

Parameters

message
Type: SystemString
The source message from which to search and extract the variables defined in it.

Return Value

Type: ListString
Returns the list of variables found in message.
Remarks
This method extracts the variables by trimming the names. That is, it takes away the characters {, $, }, which identify a variable.
Examples
The following code extracts the variables defined in a message.
// Initialise SMS object and perform authentication
ZenophSMS sms = new ZenophSMS();
sms.setUser("account_login");
sms.setPassword("account_password");
sms.authenticate();

// set the message with variables defined.
sms.setMessage("Hello {$name}, your grade in Economics is {$grade}.");

// get the variables defined in the message.
List<string> vars = sms.getVariables();

// output the variable names
for (int i = 0; i < vars.Count; ++i)
    Console.WriteLine(vars[i]);

The output of the code above is shown below:

name

grade

The characters that define a variable ({, $, }) have been taken out of the variable names.

When names of the variables must be returned without trimming them, the overloaded method getVariables(String, Boolean) should be used while setting the second argument to false in order not to trim the variable names.

See Also