首页 \ 问答 \ 使用lambda表达式获取属性名称和类型(Get property name and type using lambda expression)

使用lambda表达式获取属性名称和类型(Get property name and type using lambda expression)

我正在尝试编写一个函数,使用如下所示的语法来提取属性名称和类型:

private class SomeClass
{
    Public string Col1;
}

PropertyMapper<Somewhere> propertyMapper = new PropertyMapper<Somewhere>();
propertyMapper.MapProperty(x => x.Col1)

有没有任何方法可以将该属性传递给函数,而不会对此语法进行任何重大更改?

我想获取属性名称和属性类型。

所以在下面的例子中,我想要检索

Name = "Col1"Type = "System.String"

谁能帮忙?


I am trying to write a function that will pull the name of a property and the type using syntax like below:

private class SomeClass
{
    Public string Col1;
}

PropertyMapper<Somewhere> propertyMapper = new PropertyMapper<Somewhere>();
propertyMapper.MapProperty(x => x.Col1)

Is there any way to pass the property through to the function without any major changes to this syntax?

I would like to get the property name and the property type.

So in the example below i would want to retrieve

Name = "Col1" and Type = "System.String"

Can anyone help?


原文:https://stackoverflow.com/questions/273941
更新时间:2022-05-01 19:05

最满意答案

ls命令是文件列表命令,显示指定目录下的文件和目录列表
ls 无参数时,显示当前目录下的文件。当前目录就是指,用户操作命令时,所处的目录,可用pwd看到
ls /  参数/是根目录的意思,这表示显示根目录下的文件

其他回答

1. linux中命令没有-ls的命令,一般以-开头的是命令的参数。
2. ls命令跟dos下的dir命令是一样的都是用来列出目录下的文件,-l参数在linux下的一般作用是显示详细信息,-s参数在linux下和-l一起使用的一般作用是以块为单位列出每个文件的大小。

相关问答

更多
  • linux命令 ls'[2023-09-16]

    呵呵,这是bash的功能吧,你输入 ls" 或 ls` 都有和 ls'类似的效果。 " ' `都可以看作是引号,在命令中通常要成对出现,你只打了一个',所以系统要等你输下一个以配对处理。 这个特性有助于编写脚本。在本例中没有什么应用。
  • linux的ls命令[2022-03-07]

    麻烦 你看清楚别人的介绍 在去乱弄 归根是你的环境变量错了 环境变量都还没有弄过来 你能用上ls? PATH="$PATH:/root" 你上面的错了; PATH的引入直接错了,改回来就可以用了 PATH="/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
  • linux ls命令[2022-03-30]

    你的当前目录在Desktop下,目前这个目录里什么都没有- - 先执行 cd / 进入根目录 然后执行ls命令,肯定有东西
  • "\" -----shell中,反斜杠是起续行作用的,也就是说上面的命令其实就是 "cd home:ls", 即打开home:ls这个目录,但其实没有这个目录。 你是要打开列出home里的文件吗?试试: cd /home ls
  • 1. linux中命令没有-ls的命令,一般以-开头的是命令的参数。 2. ls命令跟dos下的dir命令是一样的都是用来列出目录下的文件,-l参数在linux下的一般作用是显示详细信息,-s参数在linux下和-l一起使用的一般作用是以块为单位列出每个文件的大小。
  • linux的ls命令[2022-05-21]

    麻烦 你看清楚别人的介绍 在去乱弄 归根是你的环境变量错了 环境变量都还没有弄过来 你能用上ls? PATH="$PATH:/root" 你上面的错了; PATH的引入直接错了,改回来就可以用了 PATH="/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
  • 回复 bikong0411 我知道APUE有例子,,struct stat是什么意思??可以大概讲讲思路吗回复 bikong0411 而且我的要求是用opendir和readdir实现的,不需要参数,,只是ls就可以了,然后列出目录以及文件
  • ls -F的意思是把文件按照类型归类,并且在末尾加上/ *等符号标识 | 连接符的意思是把前面命令的结果当做输入传给后面的命令 grep /$的意思是从中挑出以/结尾的行 PS:/标识是目录
  • ls命令是文件列表命令,显示指定目录下的文件和目录列表 ls 无参数时,显示当前目录下的文件。当前目录就是指,用户操作命令时,所处的目录,可用pwd看到 ls / 参数/是根目录的意思,这表示显示根目录下的文件
  • 每个符号用于特定类型的文件。 如果您还没有看到它们,可能是因为您没有该类型的任何文件。 ls的手册页应该说明每个人的意思。 但是,如果由于某种原因你不能读你的,这就是我的说法: -F Display a slash (`/') immediately after each pathname that is a directory, an asterisk (`*') after each that is executable, an at sign ( ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。