473,224 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

hex type values

If I assign an attribute using property name/value pairs such as
[MyAttr(stringVal="joe")]
where stringVal is a string C# generates the name\value pair using hex values
01 00 01 00 54 0E 09 73 74 72 69 6E 67 56 61 6C 03 6A 6F 65.
I've determined 54 is a delimiter between properties and the next value OE
represents the string type. Is there a complete table of hex values and their
map to all the types or a particular System.Type method I could use to get
this value?
Any documentation on this hex representation would also be helpful.

thanks - Jim
Jun 27 '08 #1
5 2205
jim <ji*@discussions.microsoft.comwrote:
If I assign an attribute using property name/value pairs such as
[MyAttr(stringVal="joe")]
where stringVal is a string C# generates the name\value pair using hex values
01 00 01 00 54 0E 09 73 74 72 69 6E 67 56 61 6C 03 6A 6F 65.
I've determined 54 is a delimiter between properties and the next value OE
represents the string type. Is there a complete table of hex values and their
map to all the types or a particular System.Type method I could use to get
this value?
Any documentation on this hex representation would also be helpful.
It's not clear to me what exactly is genering the string. You say it's
C#, but the C# compiler isn't going to be doing this for your own
custom attribute value.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #2
when running ILDASM on the following program created by C# you can see
the attribute values on the program class:

using System;
using System.Reflection;

namespace ConsoleApplication8
{
class MyAttribute : Attribute
{
private string sval;
public string stringVal
{
get { return sval; }
set { sval = value; }
}
}
[My(stringVal="joe")]
class Program
{
static void Main(string[] args)
{
}
}
}
"Jon Skeet [C# MVP]" wrote:
jim <ji*@discussions.microsoft.comwrote:
If I assign an attribute using property name/value pairs such as
[MyAttr(stringVal="joe")]
where stringVal is a string C# generates the name\value pair using hex values
01 00 01 00 54 0E 09 73 74 72 69 6E 67 56 61 6C 03 6A 6F 65.
I've determined 54 is a delimiter between properties and the next value OE
represents the string type. Is there a complete table of hex values and their
map to all the types or a particular System.Type method I could use to get
this value?
Any documentation on this hex representation would also be helpful.

It's not clear to me what exactly is genering the string. You say it's
C#, but the C# compiler isn't going to be doing this for your own
custom attribute value.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #3
[MyAttr(stringVal="joe")]

Dont know, but might it be unicode? This looks like a explanation...

In the current implementation at least, strings take up 20+(n/2)*4
bytes (rounding the value of n/2 down), where n is the number of
characters in the string. The string type is unusual in that the size
of the object itself varies.

Found at http://www.yoda.arachsys.com/csharp/strings.html

//CY
Jun 27 '08 #4
jim <ji*@discussions.microsoft.comwrote:
when running ILDASM on the following program created by C# you can see
the attribute values on the program class:
Well, you can see the IL representation - but why is that important to
you? Surely the important point is getting the attribute value in code,
which you do with reflection, where the IL representation doesn't
matter at all.

The IL representation will be documented in ECMA 335, but very few
situations will really need to know about it.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #5
jim wrote:
If I assign an attribute using property name/value pairs such as
[MyAttr(stringVal="joe")]
where stringVal is a string C# generates the name\value pair using hex values
01 00 01 00 54 0E 09 73 74 72 69 6E 67 56 61 6C 03 6A 6F 65.
I've determined 54 is a delimiter between properties and the next value OE
represents the string type. Is there a complete table of hex values and their
map to all the types or a particular System.Type method I could use to get
this value?
Any documentation on this hex representation would also be helpful.

thanks - Jim

Well, FWIW it's obvious enough that '09 73 74 72 69 6E 67 56 61 6C' is the
length of "stringVal" followed by the string itself (in 8-bit ASCII) and '03 6A
6F 65' is the length of "joe" followed by the string itself. But why in the
world do you care?

HTH,
-rick-
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Rade | last post by:
Following a discussion on another thread here... I have tried to understand what is actually standardized in C++ regarding the representing of integers (signed and unsigned) and their conversions....
8
by: BigMan | last post by:
Can someone cite the rules for type promotion in C++? And, in particular, what is the type of the result of adding 2 values of type char?
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
6
by: M.A. Oude Kotte | last post by:
Hi All, I hope this is the correct mailing list for this question. But neither postgresql.org nor google could help me out on this subject. I did find one disturbing topic on the mailing list...
7
by: Martin Robins | last post by:
I am currently looking to be able to read information from Active Directory into a data warehouse using a C# solution. I have been able to access the active directory, and I have been able to return...
10
by: Tomás | last post by:
When you simply want to store a number, what integral type do you use? For instance, let's say we have the following in a Poker game: struct Card { enum Suit { Hearts, Diamonds, Spades, Clubs...
10
by: kar1107 | last post by:
Hi all, Can the compiler chose the type of an enum to be signed or unsigned int? I thought it must be int; looks like it changes based on the assigned values. Below if I don't initialize...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
7
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.