首页 > 编程语言 >C# 自定义枚举类型转换

C# 自定义枚举类型转换

时间:2023-02-25 13:25:37浏览次数:31  
标签:类型转换 自定义 C# Enum IV Instance EAccountRole typeof

// string to enum

EAccountRole var = (EAccountRole)Enum.Parse(typeof(EAccountRole), RoleManage.Instance.CurrentAccount.Role);

 

// enum to list

public IEnumerable<EAccountRole> RoleList
{
get
{
if (RoleManage.Instance.CurrentLoginRole == EAccountRole.IV)
{
//super
return Enum.GetValues(typeof(EAccountRole)).Cast<EAccountRole>().Where(f => f != EAccountRole.IV);
}
else
{
//admin
return Enum.GetValues(typeof(EAccountRole)).Cast<EAccountRole>().Where(f => f != EAccountRole.IV || f != EAccountRole.III);
}
}
}

标签:类型转换,自定义,C#,Enum,IV,Instance,EAccountRole,typeof
From: https://www.cnblogs.com/Nongfu-Xiang/p/17154217.html

相关文章

  • Vectors, what even are they?
    InterpretationsofVectorsPhysicsPerspective:vectorsarearrowspointinginspace.CSPerspective:vectorsareorderedlistsofnumbers.Mathematician's......
  • Containerd 客户端工具
    当我们的k8s没有使用docker的容器运行时的时候,管理查询镜像就需要用到其他Containerd客户端工具containerd的客户端工具有ctr,crictl和nerdctlctr和crictlctr是由c......
  • 一个简易socket通信结构
    服务端工作需要又需要用到socketTCP通讯,这么多年了,终于稍微能写点了。让我说其实也说不出个啥来,看了很多的异步后稍微对异步socket的导流endreceive后再beginreceive形......
  • ThreadLocal基本使用和源码解读
    1基本使用ThreadLocal的作用是保存线程本地变量,在多线程在CPU时间分片交替执行过程中,每个线程只能获取到它自己的数据。ThreadLocal的使用非常简单:创建ThreadLocal。......
  • Golang Slice
    Golang—SliceSlice是Go语言中的一种数据类型,又称动态数组,依托数组实现,可以方便的进行扩容、传递等,实际使用中比数组更灵活。实现原理Slice依托数组实现,底层数组对......
  • docker基础与概念
    什么是dockerDocker使用Google公司推出的Go语言进行开发实现,基于Linux内核的cgroup,namespace,对进程进行封装隔离,属于操作系统层面的虚拟化技术。由于隔离的进程独立于宿......
  • CompletableFuture 异步编排
    业务场景查询商品详情页的逻辑比较复杂,有些数据还需要远程调用,必然需要花费更多的时间。假如商品详情页的每个查询,需要如下标注的时间才能完成那么,用户需要5.5s后才能看......
  • 一种图片展示的完美方案,图片展示,object-fill
    通常一般的处理<style>.img-container{width:300px;height:200px;background:#f60;}img{width:100%;height:100%;}......
  • 【Java】 java | java连接mysql报错 | Unsupported record version Unknown-0.0
    一、错误信息UnsupportedrecordversionUnknown-0.0二、问题jdbc的ssl连接问题三、解决jdbc:mysql://192.168.100.122:3306/torna?useUnicode=true&characterEncoding=utf......
  • Component name “School“ should always be multi-word
    脚手架报错:Componentname“School”shouldalwaysbemulti-word原因是语法检测的问题,只要关闭语法检测就可以了。解决方法:在项目目录里找到vue.config.js关闭语法检......