在C#中使用重复的枚举 [英] use duplicate enum in C#

查看:361
本文介绍了在C#中使用重复的枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





Hi,

public enum Clothes
{
public enum Skirts{FLORAL,SHORT}
public enum Shirts{BUTTONED,TUNIC}
}



我希望能够在我的程序中写下这样的东西:


I want to be able to write in my program something like this:

Shop s=new Shop(Clothes.Skirts.FLORAL,Clothes.Shirts.TUNIC}









如何用C#做这样的事情?



谢谢





How can I do something like this in C#?

Thanks

推荐答案

你可以尝试这样..





you can try like this..


class Program
{
    static void Main(string[] args)
    {
        Shop s = new Shop(Clothes.Skirts.FLORAL, Clothes.Shirts.TUNIC);
    }


}
public class Clothes
{
    public enum Skirts { FLORAL, SHORT }
    public enum Shirts { BUTTONED, TUNIC }
}
public class Shop
{
    public Shop(Clothes.Skirts param1, Clothes.Shirts param2)
    {

    }
}


这篇关于在C#中使用重复的枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆