0

I am trying to append data to memcached using C# Enyim.Caching but it forces me to send data as ArraySegment

public bool Append(string key, ArraySegment<byte> data);

How do I convert a string or array of strings to ArraySegment ?

Is there a better way to use Append?

Vonetizer
  • 383
  • 1
  • 3
  • 4

1 Answers1

0

I was able to find out how to do this. In order to convert a string to ArraySegment<byte> use the following code.

byte[] arrByte = Encoding.ASCII.GetBytes(data);
ArraySegment<byte> data = new ArraySegment<byte>(arrByte, 0, arrByte.Length);

Hope this helps someone!

Vonetizer
  • 383
  • 1
  • 3
  • 4
  • What format does it come back in when you use 'get'? Is it simply a byte array? If so, how did you get that back to string? Curious because I'm trying all the usual ways and it's not working. – BlackjacketMack Aug 19 '17 at 19:56