简体   繁体   中英

What is `using a = Func<>;` syntax in C#?

What is the name of this syntax? How can I use it?

using AppFunc = Func<IDictionary<string, object>, System.Threading.Tasks.Task>;
public class A
{
}

using normally used to import namespace to use in that file

But it could be used to make an alias to shorten a long or complicate type with that syntax

For example

using Dict = Dictionary<string,string>

When you call

Dict dict = new Dict();

at compile time it will be convert to

Dictionary<string,string> dict = new Dictionary<string,string>()

It just syntactic sugar like #DEFINE in C++

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM