How to read value of type “IBuffer” as string in c

2020-04-07 19:46发布

How can I copy a variable which is of type IBuffer in C# (UWP app) to a string? The IBuffer itself doesn't seem to have any methods. It has Length which seems to be the correct value. But I cannot see the value in debugger (says requires Native debugging). Below is the class. I need to get Data.

public sealed class MagneticStripeReaderTrackData : IMagneticStripeReaderTrackData
{
    public IBuffer Data { get; }

标签: c# uwp
1条回答
▲ chillily
2楼-- · 2020-04-07 20:03

For example you can use it like this:

var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(Data);
var output = dataReader.ReadString(Data.Length);

You can find same example here. https://msdn.microsoft.com/ru-ru/library/windows/apps/hh464978

查看更多
登录 后发表回答