473,386 Members | 1,710 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,386 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 2208
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.