如何从struct name获取struct?

编程入门 行业动态 更新时间:2024-10-13 02:14:36
本文介绍了如何从struct name获取struct?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好b $ b 有可能获得例如来自字符串值 System.Int16 struct , 或例如从System.Single我需要 struct float 。 我不是指使用Type.GetType(System.Int16) - 这是不同的事情(因为它返回类型,但我需要 struct ) 我上传我的意思(不同) postimg/image/ouy2xhzjr/ [ ^ ] 存在任何可以使用的方法 (method1(short))12 或(method1(System.Int16))12 而不是 (短)12 谢谢

解决方案

Int16 and short不一样...... short是一个表示C#语言的INTEGRAL类型的关键字(而不是.NET faremwork的类型),其中Int16是.NET框架类型。 确实两者都代表一个16位的有符号整数,但这都是...... 你不能写一个并期望得到另一个... 两种不同类型的原因是.NET框架可以使用不同的语言,如PHP或COBOL,其中short不是一个选项。 ..但那些语言也使用Int16,根据定义独立于语言......

你可以使用 typeof :

typeof ( short )

Hi It is possible get e.g. from string value "System.Int16" struct short, or e.g. from "System.Single" I need struct float. I don't mean use Type.GetType("System.Int16") - this is different thing (because it return Type, but I need struct) I upload what I mean (different) postimg/image/ouy2xhzjr/[^] Exist any method who can use (method1("short"))12 or (method1("System.Int16"))12 instead (short)12 Thank you

解决方案

Int16 and short ARE NOT the same... short is a keyword that represents an INTEGRAL type of the C# language (and not a type of the .NET faremwork), where Int16 is a .NET framework type. It is true that both are representing a 16 bit usigned integer, but that's all... You can not write the one and expecting to get the other... The reason for the two different types is that .NET framework can be used from different languages, like PHP or COBOL, where short not an option...but those languages too an use Int16, that by definition independent of languages...

You can use typeof:

typeof(short)

更多推荐

如何从struct name获取struct?

本文发布于:2023-10-08 14:54:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1472952.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:struct

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!