Reputation: 50170
ie something like
typedef Dictionary<string, string> mydict;
I swear I have seen it but cannot find it
Upvotes: 10
Views: 6075
Reputation: 18068
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.
Upvotes: 0
Reputation: 21
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" }
}}};
Upvotes: 2
Reputation: 89172
Sort of.
using IntList = System.Collections.Generic.List<int>;
http://arbel.net/2004/07/07/the-hidden-c-typedef/
One issue is there is no way to #include the definition.
Upvotes: 5
Reputation: 69
There is no equivalent of typedef in C#, however you could use 'using' for aliases.
Upvotes: 0
Reputation: 4711
using MyDict = Dictionary<String, String>
which is like defining a symbol which would be replaced by the compiler.
Upvotes: 19