Home > Net >  C #, please can you define a data type such as int
C #, please can you define a data type such as int

Time:03-30

As we know, in c #, int is System. Int32 alias, however, such an alias to define?
My needs are: the program, the extensive use of Dictionary Type used for parameter passing,
So I need in most of the writing Dictionary< program; String, object> , it's too long, want to customize a type name, such as: myDic, can let the program know that it is equivalent to Dictionary ,

Tried to write this a static class to implement global:
Public static myDic: Dictionary {}
Make myDic Dictionary The derived class,
But in actual development process, the derived class can be directly to the parent class, need packing conversely, when the parameters of the function is defined as the myDic, are not directly Dictionary Type, need (myDic) to the box, and trouble,

What exactly have what good method, to write a myDic data type?

CodePudding user response:

To use an alias?
Into the Namespace
Using MyDic=System. Collections. Generic. Dictionary;

CodePudding user response:

Do you want to need not dynamic

CodePudding user response:

IDictionary

CodePudding user response:

God using the term, which was packing

Words, don't follow the great gods, the great god himself all mixed up, so to god every day of the great god, god in the face of a resume, in the face of HR, write some fool type article, known as the media, but have since the media is all some what person, you should know better,

CodePudding user response:

The
refer to the original poster piao2004 response:
we know that in c #, int is System. Int32 alias, however, such an alias to define?
My needs are: the program, the extensive use of Dictionary Type used for parameter passing,
So I need in most of the writing Dictionary< program; String, object> , it's too long, want to customize a type name, such as: myDic, can let the program know that it is equivalent to Dictionary ,

Tried to write this a static class to implement global:
Public static myDic: Dictionary {}
Make myDic Dictionary The derived class,
But in actual development process, the derived class can be directly to the parent class, need packing conversely, when the parameters of the function is defined as the myDic, are not directly Dictionary Type, need (myDic) to the box, and trouble,

What exactly have what good method, to write a myDic data type?


I carefully looked at it and feel that it is not like the custom type problem, it's a matter of global object definition,

CodePudding user response:

,,,,,,,
Then you direct public static Dictionary MyDic=new Dictionary (a);
Then the global myDic is not good,
  •  Tags:  
  • C#