[英]Shorter names to gain access to a class in C#
Just need some advise since I'm new to this. 只是需要一些建议,因为我是新手。 Is there a way I can make this shorter?
有什么办法可以缩短它的时间吗?
Student.Classes.Enum.Enum.gender
Just need a smarter way to do this. 只需要一种更聪明的方式即可做到这一点。
You can use an alias in import like so: 您可以在导入中使用别名,如下所示:
using System;
using System.Collections.Generic;
using ShortAlias = Very.Long.Class.Name;
class Test
{
private ShortAlias x;
}
you should read up on 'using' statements 您应该阅读“使用”声明
ie 即
using Student.Classes.Enum.Enum;
would allow you to use 将允许您使用
gender.Male
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.