Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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)
http://postimg.org/image/ouy2xhzjr/[^]

Exist any method who can use
(method1("short"))12 or (method1("System.Int16"))12
instead
(short)12

Thank you
Posted
Updated 10-Mar-15 22:32pm
v3
Comments
Kornfeld Eliyahu Peter 11-Mar-15 3:36am    
System.Int16 and System.Single ARE structs...So not clear what do you mean...
smoula99 11-Mar-15 3:49am    
in debug mode at Watch window you write:
short (and to next row) Type.GetType("System.Int16") and you see different

short - is type short
Type.GetType("System.Int16") - is type System.Type

I need wite string "System.Int16" (I not write short), but I want struct short

e.g example where is possible to use
(short)12 - but I have variable type and in time, that I need use (something"System.Int16")12
OriginalGriff 11-Mar-15 3:46am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
So while this all means a lot to you, we don't have any context for it - so it means absolutely nothing to us.
Try explaining in more detail: we can't help you based on that.
Use the "Improve question" widget to edit your question and provide better information.

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...
 
Share this answer
 
You can use typeof:
C#
typeof(short)
 
Share this answer
 
Comments
smoula99 12-Mar-15 4:26am    
but "short" must by as string not as struct

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900