Question: To encode a string

Code:

```
public string base64Encode(string data)
{
    try
    {
        byte[] encData_byte = new byte[data.Length];
        encData_byte = System.Text.Encoding.UTF8.GetBytes(data);    
        string encodedData = Convert.ToBase64String(encData_byte);
        return encodedData;
    }
    catch(Exception e)
    {
        throw new Exception("Error in base64Encode" + e.Message);
    }
}

```

Answer: 
```
public string Base64Decode(string data)
{
    byte[] byteArray = Convert.FromBase64String(data);
    var message = System.Text.Encoding.UTF8.GetString(byteArray);
    return message;
}

```
Have a look at `Convert.FromBase64String`.