Enum in Python,Java,C#

2023-12-17 10:53:53

python:

# encoding: utf-8
# 版权所有 2023 ?涂聚文有限公司
# 许可信息查看:
# 描述: 语言种类枚举类型
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2023.1 python 3.11
# Datetime  : 2023/12/15 9:34
# User      : geovindu
# Product   : PyCharm
# Project   : EssentialAlgorithms
# File      : LanguageList.py
# explain   : 学习
 
from enum import Enum
 
class Lang(Enum):
    """
    语言类型
    获取语言类型名称字符串  Common.LanguageList.Lang.zh_cn.name
    """
    af= 'af', # Afrikaans
    al= 'al', # Albanian
    ar= 'ar', # Arabic
    az= 'az', # Azerbaijani
    bg= 'bg', # Bulgarian
    ca= 'ca', # Catalan
    cz= 'cz', # Czech
    da= 'da', # Danish
    de= 'de', # German
    el= 'el', # Greek
    en= 'en', # English
    """
    英文
    """
    eu= 'eu', # Basque
    fa= 'fa', # Persian(Farsi)
    fi= 'fi', # Finnish
    fr='fr', # French
    gl='gl', # Galician
    he='he', # Hebrew
    hi='hi', # Hindi
    hr='hr', # Croatian
    hu='hu', # Hungarian
    id='id', # Indonesian
    it='it', # Italian
    ja='ja', # Japanese
    kr='kr', # Korean
    la='la', # Latvian
    lt='lt', # Lithuanian
    mk='mk', # Macedonian
    no='no', # Norwegian
    nl='nl', # Dutch
    pl='pl', # Polish
    pt='pt', # Portuguese
    pt_br='pt_br', # Português    Brasil
    ro='ro', # Romanian
    ru='ru', # Russian
    sv='sv', # se    Swedish
    se='se',
    sk='sk', # Slovak
    sl='sl', # Slovenian
    sp='sp', # es    Spanish
    es='es',
    sr='sr', # Serbian
    th='th', # Thai
    tr='tr', # Turkish
    ua='ua', # uk    Ukrainian
    vi='vi', # Vietnamese
    zh_cn='zh_cn', # Chinese    Simplified
    """
    简体中文
    """
    zh_tw='zh_tw', # Chinese    Traditional
    """
    繁体中文
    """
    zu='zu' # Zulu

java:

/**
 * encoding: utf-8
 * 版权所有 2023 涂聚文有限公司
 * 许可信息查看:
 * 描述:
 * # Author    : geovindu,Geovin Du 涂聚文.
 * # IDE       : IntelliJ IDEA 2023.1 Java 17
 * # Datetime  : 2023 - 2023/12/15 - 20:09
 * # User      : geovindu
 * # Product   : IntelliJ IDEA
 * # Project   : javademo
 * # File      : LanguageList.java  类
 * # explain   : 学习
 **/
 
package Common;
 
 
import java.util.*;
import java.lang.Enum;
 
 
/**
 * 语言类型名称实体
 */
public enum LanguageList {
 
    af("af", 1),//"Afrikaans"
    al("al",2),//" Albanian"
    ar("ar",3),//" Arabic"
    az("az",4),//
    bg("bg",5),//" Bulgarian"
    ca("ca",6),//" Catalan"
    cz("cz",7),//
    da("da",8),//" Danish"
    de("de",9),//" German"
    el("el",10),//" Greek"
    /**
     * 英文
     */
    en("en",11),//" English"
 
    eu("eu",12),//" Basque"
    fa("fa",13),//" Persian(Farsi)"
    fi("fi",14),//" Finnish"
    fr("fr",15),//" French"
    gl("gl",16),//" Galician"
    he("he",17),//" Hebrew"
    hi("hi",18),//" Hindi"
    hr("hr",19),//" Croatian"
    hu("hu",20),//" Hungarian"
    id("id",21),//" Indonesian"
    it("it",22),//" Italian"
    ja("ja",23),//" Japanese"
    kr("kr",24),//" Korean"
    la("la",25),//" Latvian"
    lt("lt",26),//" Lithuanian"
    mk("mk",27),//" Macedonian"
    no("no",28),//" Norwegian"
    nl("nl",29),//" Dutch"
    pl("pl",30),//" Polish"
    pt("pt",31),//" Portuguese"
    pt_br("pt_br",32),//" Português    Brasil"
    ro("ro",33),//" Romanian"
    ru("ru",34),//" Russian"
    sv("sv",35),//" se    Swedish"
    se("se",36),
    sk("sk",37),//" Slovak"
    sl("sl",38),//" Slovenian"
    sp("sp",39),//" es    Spanish"
    es("es",40),
    sr("sr",41),//" Serbian"
    th("th",42),//" Thai"
    tr("tr",43),//" Turkish"
    ua("ua",44),//" uk    Ukrainian"
    vi("vi",45),//" Vietnamese"
    /**
     * 简体中文
     */
    zh_cn("zh_cn",46),//" Chinese    Simplified"
    /**
     * 繁体中文
     */
    zh_tw("zh_tw",47),//" Chinese    Traditional"
 
    zu("zu",48);//"Zulu"
 
    /**
     * 值、名称 成员变量
     */
    private String name;
    /**
     * 索引值 序号
     */
    private int index;
 
    /**
     * 构造方法
     * @param name
     * @param index
     */
    private LanguageList(String name, int index) {
        this.name = name;
        this.index = index;
    }
 
    /**
     * 普通方法
     * @param index
     * @return
     */
    public static String getName(int index) {
        for (LanguageList c : LanguageList.values()) {
            if (c.getIndex() == index) {
                return c.name;
            }
        }
        return null;
    }
    //get set 方法
    /**
     *
     * @return
     */
    public String getName() {
        return name;
    }
 
    /**
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }
 
    /**
     *
     * @return
     */
    public int getIndex() {
        return index;
    }
 
    /**
     *
     * @param index
     */
    public void setIndex(int index) {
        this.index = index;
    }
 
 
 
 
}

CSharp:

/*
 file: languageList.cs
 * geovindu,Geovin,涂聚文
 */
 
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Geovin.Du.Common
{
    /// <summary>
    /// 语言种类枚举类型
    ///
    /// </summary>
    public enum Lang  //:string .net 8
    {
        af,// Afrikaans
        al,// Albanian
        ar,// Arabic
        az,// Azerbaijani
        bg,// Bulgarian
        ca,// Catalan
        cz,// Czech
        da,// Danish
        de,// German
        el,// Greek
        /// <summary>
        /// 英文
        /// </summary>
        en,// English
        eu,// Basque
        fa,// Persian (Farsi)
        fi,// Finnish
        fr,// French
        gl,// Galician
        he,// Hebrew
        hi,// Hindi
        hr,// Croatian
        hu,// Hungarian
        id,// Indonesian
        it,// Italian
        ja,// Japanese
        kr,// Korean
        la,// Latvian
        lt,// Lithuanian
        mk,// Macedonian
        no,// Norwegian
        nl,// Dutch
        pl,// Polish
        pt,// Portuguese
        pt_br,// Português Brasil
        ro,// Romanian
        ru,// Russian
        sv,// se Swedish
        se,
        sk,// Slovak
        sl,// Slovenian
        sp,// es Spanish
        es,
        sr,// Serbian
        th,// Thai
        tr,// Turkish
        ua,// uk Ukrainian
        uk,
        vi,// Vietnamese
        /// <summary>
        /// 简体中文
        /// </summary>
        zh_cn,// Chinese Simplified
        /// <summary>
        /// 繁体中文
        /// </summary>
        zh_tw,// Chinese Traditional
        zu// Zulu
 
    }
}

文章来源:https://blog.csdn.net/geovindu/article/details/135041203
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。