How to create a [Reusable] Function in [C#.NET]
Creating a reusable function lets you use it anywhere in your code project.
I first created an identical function for ASP Classic and needed something similar in ASP.NET.
[ASP.NET C# - Reusable Replace Function]
CFFCS | CarrzSynEdit: | ASP.NET (VB/C#)

    //Encode (Change Characters)
    public string Encoding(string strEncoding)
        {
        strEncoding = strEncoding.Replace(")", "}");
        strEncoding = strEncoding.Replace("(", "{");
        strEncoding = strEncoding.Replace(" ", "_");
        return strEncoding;
        {


    //Decode (Change Characters back to their original Characters.)
    public string Decoding(string strEncoding)
    {
        strEncoding = strEncoding.Replace("}", ")");
        strEncoding = strEncoding.Replace("{", "(");
        strEncoding = strEncoding.Replace("_", " ");
        return strEncoding;
    {

To use in your ASP.NET C# project, simply copy the above code and paste it into your project, replacing only the string characters you need to replace in your project.
To reuse this function, do the following
[ASP.NET C# - Endoding/Decoding a String]
CFFCS | CarrzSynEdit: | ASP.NET (VB/C#)

    public void Page_Load(object Sender, EventArgs e)
        {
            Response.Write(Encoding("Test (This is a test)"));
            Response.Write(Decoding("Test {This is a test}"));
        {

The above example will
  1. Replace the Parentheses with {curly brackets} and add underscores where spaces are at.Output: Test_{This_is_a_test}
  2. Replace the {curly brackets} with Parentheses and remove the underscores.Output: Test (This is a test);
Other Articles Related to this Entry.