Previous Code Entry
Left Arrow
ASP.NET Column & Paging System with C#
Current Code Entry
Go Back To Code List
ASP.NET - How to create a Reusable Replace Function in C#.NET
Article Entry Date: April 18,2024 @ 03:52:26 / Last Updated On: April 18,2024 @ 03:55:32
How to create a [Reusable] Function in [C#.NET]

Making a reusable function allows you to use the function anywhere within your code project.
I first created an identical function for ASP Classic and needed something similar in

To use in your 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

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.

ASP.NET - How to create a Reusable Replace Function in VB.NET«
ASP Classic - How to create a Reusable Replace Function«