So here we will use console application demonstrate. So, for this article we will create a new console application using c#.net.
string [] stringArray = ["C#.net","VB.Net","Asp.Net",".Net MVC", "React Js","Angular Js","jQuery"];
var jsonValue = JsonSerializer.Serialize(stringArray);
byte[] byteArray = Encoding.UTF8.GetBytes(jsonValue);
var memoryStreamData = new MemoryStream(byteArray);
Now let's discuss each and every line written in above code. Let's check the first line of code. string [] stringArray = ["C#.net","VB.Net","Asp.Net",".Net MVC", "React Js","Angular Js","jQuery"];
In above code i have declared the array of string type. Here in this array i have added some values. There we going to convert into memory stream by using MemoryStream(byteArray). So before using MemoryStream(byteArray) we need to perform few steps.
var jsonValue = JsonSerializer.Serialize(stringArray);
Here in above code, I have converted the array of string into Json string by using JsonSerializer.Serialize(stringArray). This will convert array into string.
byte[] byteArray = Encoding.UTF8.GetBytes(jsonValue);
Now let's check what we are getting in the byte array.
Bye array we will pass it in the MemoryStream(byteArray) to convert into the MemoryStream. Please check the below piece of code.