Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

JavaScriptSerializer() and convert to base64

class Program
{
    static void Main(string[] args)
    {
        var account = new ExternalAccount() { Name = "Someone" };
        string json = JsonConvert.SerializeObject(account);
        string base64EncodedExternalAccount = Convert.ToBase64String(Encoding.UTF8.GetBytes(json));
        byte[] byteArray = Convert.FromBase64String(base64EncodedExternalAccount);

        string jsonBack = Encoding.UTF8.GetString(byteArray);
        var accountBack = JsonConvert.DeserializeObject<ExternalAccount>(jsonBack);
        Console.WriteLine(accountBack.Name);
        Console.ReadLine();
    }
}

[Serializable]
public class ExternalAccount
{
    public string Name { get; set; }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: load information with txt file to uwp c# 
Csharp :: example of List c# 
Csharp :: httpclient getstringasync 
Csharp :: dapper get list 
Csharp :: instantiate an array in c# 
Csharp :: c# system cryptography hash string 
Csharp :: convert from data adapter to Ienumerable C# 
Csharp :: asp.net call controller from another controller 
Csharp :: C# random multiple of 5 in range 
Csharp :: tachyons 
Csharp :: usermanager find based on role 
Csharp :: c# slice array 
Csharp :: c# while loops 
Csharp :: c# sbyte 
Csharp :: c# convert xml to list string 
Csharp :: how to create class in c# 
Csharp :: oauth API with the Access Token to retrieve some of users information. 
Csharp :: c# how to check the minimum and maximum of numbers 
Csharp :: quaternion to euler 
Csharp :: delete all fields that start with mongo 
Csharp :: c# exit foreach 
Csharp :: c# sequential struct with fixed array size 
Csharp :: blazor use static json files 
Csharp :: c# driver.findelement to look for declared variable 
Csharp :: c# get program version 
Csharp :: Bedingungen in C# – if, else und else if 
Csharp :: user (current login user) in viewcomponent 
Csharp :: how to get user browser information in .net core 
Csharp :: how to add extra window to wpf 
Csharp :: build url mvs view 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =