473,813 Members | 4,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hex type values

If I assign an attribute using property name/value pairs such as
[MyAttr(stringVa l="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 2225
jim <ji*@discussion s.microsoft.com wrote:
If I assign an attribute using property name/value pairs such as
[MyAttr(stringVa l="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.co m>
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.Reflecti on;

namespace ConsoleApplicat ion8
{
class MyAttribute : Attribute
{
private string sval;
public string stringVal
{
get { return sval; }
set { sval = value; }
}
}
[My(stringVal="j oe")]
class Program
{
static void Main(string[] args)
{
}
}
}
"Jon Skeet [C# MVP]" wrote:
jim <ji*@discussion s.microsoft.com wrote:
If I assign an attribute using property name/value pairs such as
[MyAttr(stringVa l="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.co m>
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(stringVa l="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*@discussion s.microsoft.com wrote:
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.co m>
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(stringVa l="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
2252
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. The reference should be 3.9.1 (Fundamental types), and 4.7 (Integral conversions). It seems to me that the Standard doesn't specify: 1) The "value representation" of any of these types, except that (3.9.1/3) "... The range of nonnegative...
8
4859
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
4574
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 there something wrong in there? -------------------------------------------------------------------- Types A type is a definition for a sequence of storage bits. It gives the meaning of the data stored in memory. If we say that the object a is an
6
9234
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 archives (http://archives.postgresql.org/pgsql-admin/2000-05/msg00032.php), but since it was quite old I'm posting my question anyway. I'm writing a generic database layer that should support a fixed number of generic numeric types on a number of...
7
11964
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 "DirectoryEntry" objects within the path that I specify (either using the DirectoryEnrtry.Children or using the DirectorySearcher class) and all started well and dandy! Now the problem; some of the properties of the DirectoryEntry objects being...
10
2907
by: Toms | 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 } suit; int value; };
10
23620
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 FOO_STORE to be, say -10, I get a warning about unsigned comparison and I'm seeing an infinite loop. If I do initialize FOO_STORE = -10, I don't see any warnings. No infinite loop.
669
26285
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 paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
7
9840
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
2
3099
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 section: Discography --------------------- DiscID
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10139
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5568
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.