How can I create a parameterized properties in C#.
public readonly string ConnectionString(string ConnectionName)
{
    get { return System.Configuration.ConfigurationManager.ConnectionStrings[ConnectionName].ToString(); }
}
                The only type of parameterized property you can create in C# is an indexer property:
public class MyConnectionStrings
{
    private string GetConnectionString(string connectionName) { ... }
    public string this[string connectionName]
    {
        get { return GetConnectionString(connectionName); }
    }
}
Otherwise, just create a method instead - that seems to be closer to what you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With