Alex Rivera | Logout

Is there an equivalent to typedef in c#?

Asked 2011-05-18T17:53:42.920
10

ie something like

typedef Dictionary<string, string> mydict;

I swear I have seen it but cannot find it

Edit
Report

2 Answers

2

use inheritance:

public class DoubleNameValueCollection : Dictionary< string, NameValueCollection > { }

Then use as if it were a typedef:

NameValueCollection values = new NameValueCollection();
values.Add( "value1", "value2" );
DoubleNameValueCollection dblNameCol = new DoubleNameValueCollection();
dblNameCol.Add( "key1", values );

Or if you want to confuse others:

DoubleNameValueCollection dblNameCol = new DoubleNameValueCollection
    {
        { "key1", new NameValueCollection 
            {
                { "value1", "value2" }
    }}};   
answered 2013-03-15T01:49:39.480
0

There is delegate, which is used for defining a type of method argument,

there is using BlaBla = Full.Name.Space.Yada.Yada;

however, the using statement is only valid in current file.

answered 2011-05-18T17:58:30.170

Your Answer