<p>I'd like to do the same in C#. Is there anyway of using properties in C# with parameters in the same way I've done with the parameter 'Key' in this VB.NET example?</p>

<blockquote>
<pre><code>Private Shared m_Dictionary As IDictionary(Of String, Object) = New Dictionary(Of String, Object)
</code></pre>
</blockquote>

<pre><code>Public Shared Property DictionaryElement(ByVal Key As String) As Object
    Get
        If m_Dictionary.ContainsKey(Key) Then
            Return m_Dictionary(Key)
        Else
            Return [String].Empty
        End If
    End Get
    Set(ByVal value As Object)
        If m_Dictionary.ContainsKey(Key) Then
            m_Dictionary(Key) = value
        Else
            m_Dictionary.Add(Key, value)
        End If

    End Set
End Property
</code></pre>

<p>Thanks</p>

Is there anyway of using properties in C# with parameters
No. You only can provide the
default
property in C# with an argument, to model indexed access (as in a dictionary):
```
```
public T this[string key] {
    get { return m_Dictionary[key]; }
    set { m_Dictionary[key] = value; }
}
```
```
Other properties can't have arguments. Use a function instead. By the way, it's recommented to do the same in VB so other .NET languages (C# …) can use your code.
By the way, your code is unnecessarily complicated. Four things:
You don't need to escape the
```
String
```
identifier. Use the keyword directly.
Why not use
```
""
```
?
Use
```
TryGetValue
```
, it's faster. You query the dictionary twice.
Your setter doesn't have to test whether the value already exists.
```
```
Public Shared Property DictionaryElement(ByVal Key As String) As Object
    Get
        Dim ret As String
        If m_Dictionary.TryGetValue(Key, ret) Then Return ret
        Return "" ' Same as String.Empty! '
    End Get
    Set(ByVal value As Object)
        m_Dictionary(Key) = value
    End Set
End Property
```
```