Reputation: 326
The desktop client we use with our phone system has an API which allows us to capture the telephone number of the phone as it rings. In order to use the API you reference a DLL and specify.
using TelephonyProxy;
public class program
{
private static Commander commander;
private static Listener listener;
static void Main()
{
commander = new Commander();
listener = new Listener();
SubscribeToListener();
}
private static void SubcribeToListener()
{
Debug.WriteLine("Subscribe To Listener");
listener.Connect += OnConnect;
listener.Disconnect += OnDisconnect;
listener.Offering += OnOffering;
listener.Ringback += OnRingback;
}
private static void OnOffering(string name, string number)
{
Debug.WriteLine(number + “abc”);
}
}
The issue is the OnOffering is called correctly and the telephone number is in the number variable. However the debug only shows the number and not the “abc”. In testing it seems you can concatenate anything in front of number but anything after is ignored.
Have you any idea why that might be?
Thanks for any input you can give this.
Upvotes: 0
Views: 96
Reputation: 38737
ASCII character 0 (represented in the debugger as \0) is sometimes used to terminate strings. If you're dealing with something like a COM device, etc., this may be the case.
For example:
Debug.WriteLine("a\0b");
will only output "a". ASCII character 0 is not printed, nor are any of the subsequent characters. Naturally, appending something to such a string will mean that anything after \0 in the original string, nothing will appear.
If you're dealing with COM, look at the string in the debugger and see if \0 is on the end.
You could remove it using replace:
Debug.WriteLine(number.Replace("\0", "") + "abc");
Upvotes: 2