Click here to Skip to main content
15,899,314 members
Home / Discussions / C#
   

C#

 
QuestionPassing an array to a method? Pin
Kuang Cao27-Jul-06 8:46
Kuang Cao27-Jul-06 8:46 
AnswerRe: Passing an array to a method? Pin
Ennis Ray Lynch, Jr.27-Jul-06 8:49
Ennis Ray Lynch, Jr.27-Jul-06 8:49 
AnswerRe: Passing an array to a method? Pin
Judah Gabriel Himango27-Jul-06 9:35
sponsorJudah Gabriel Himango27-Jul-06 9:35 
QuestionControl highlighting prevention Pin
Imtiaz Murtaza27-Jul-06 8:32
Imtiaz Murtaza27-Jul-06 8:32 
AnswerRe: Control highlighting prevention Pin
mav.northwind27-Jul-06 9:47
mav.northwind27-Jul-06 9:47 
QuestionHow implement this Pin
Legolas.Bilbao27-Jul-06 8:31
Legolas.Bilbao27-Jul-06 8:31 
QuestionHow can I programm the inner representation of a decimal number? Pin
HilSoft27-Jul-06 7:44
HilSoft27-Jul-06 7:44 
AnswerRe: How can I programm the inner representation of a decimal number? Pin
Dustin Metzgar27-Jul-06 8:08
Dustin Metzgar27-Jul-06 8:08 
If you use Reflector, you can see what the underlying implementation is for Decimal. For instance, there's an internal method called GetBytes that looks like this:
internal static void GetBytes(decimal d, byte[] buffer)
{
      buffer[0] = (byte) d.lo;
      buffer[1] = (byte) (d.lo >> 8);
      buffer[2] = (byte) (d.lo >> 0x10);
      buffer[3] = (byte) (d.lo >> 0x18);
      buffer[4] = (byte) d.mid;
      buffer[5] = (byte) (d.mid >> 8);
      buffer[6] = (byte) (d.mid >> 0x10);
      buffer[7] = (byte) (d.mid >> 0x18);
      buffer[8] = (byte) d.hi;
      buffer[9] = (byte) (d.hi >> 8);
      buffer[10] = (byte) (d.hi >> 0x10);
      buffer[11] = (byte) (d.hi >> 0x18);
      buffer[12] = (byte) d.flags;
      buffer[13] = (byte) (d.flags >> 8);
      buffer[14] = (byte) (d.flags >> 0x10);
      buffer[15] = (byte) (d.flags >> 0x18);
}


You could use reflection to call that internal method or you could use GetBits and convert the integers to bytes yourself. Here's what GetBits looks like:

public static int[] GetBits(decimal d)
{
      return new int[] { d.lo, d.mid, d.hi, d.flags };
}


To convert the bits back into a Decimal, you can use the constructor that takes an int array. The array is in the same format that is output by GetBits.




Logifusion[^]
GeneralRe: How can I programm the inner representation of a decimal number? Pin
HilSoft27-Jul-06 8:33
HilSoft27-Jul-06 8:33 
GeneralRe: How can I programm the inner representation of a decimal number? Pin
Dan Neely27-Jul-06 8:40
Dan Neely27-Jul-06 8:40 
GeneralRe: How can I programm the inner representation of a decimal number? Pin
HilSoft27-Jul-06 8:47
HilSoft27-Jul-06 8:47 
GeneralRe: How can I programm the inner representation of a decimal number? Pin
Dan Neely27-Jul-06 9:31
Dan Neely27-Jul-06 9:31 
GeneralRe: How can I programm the inner representation of a decimal number? [modified] Pin
HilSoft27-Jul-06 10:04
HilSoft27-Jul-06 10:04 
AnswerRe: How can I programm the inner representation of a decimal number? Pin
Not Active27-Jul-06 8:15
mentorNot Active27-Jul-06 8:15 
GeneralRe: How can I programm the inner representation of a decimal number? Pin
HilSoft27-Jul-06 8:52
HilSoft27-Jul-06 8:52 
QuestionDelegates Pin
~~~Johnny~~~27-Jul-06 6:55
~~~Johnny~~~27-Jul-06 6:55 
AnswerRe: Delegates Pin
Dustin Metzgar27-Jul-06 7:03
Dustin Metzgar27-Jul-06 7:03 
GeneralRe: Delegates Pin
~~~Johnny~~~27-Jul-06 7:10
~~~Johnny~~~27-Jul-06 7:10 
GeneralRe: Delegates Pin
Dustin Metzgar27-Jul-06 7:34
Dustin Metzgar27-Jul-06 7:34 
GeneralRe: Delegates Pin
~~~Johnny~~~27-Jul-06 8:26
~~~Johnny~~~27-Jul-06 8:26 
QuestionPivotTable and SpreadSheet Components [modified] Pin
hamidreza_buddy27-Jul-06 6:54
hamidreza_buddy27-Jul-06 6:54 
Questionoverload native function Pin
donkaiser27-Jul-06 5:57
donkaiser27-Jul-06 5:57 
AnswerRe: overload native function Pin
J4amieC27-Jul-06 6:02
J4amieC27-Jul-06 6:02 
GeneralRe: overload native function [modified] Pin
donkaiser27-Jul-06 6:06
donkaiser27-Jul-06 6:06 
GeneralRe: overload native function Pin
Ennis Ray Lynch, Jr.27-Jul-06 6:23
Ennis Ray Lynch, Jr.27-Jul-06 6:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.