Click here to Skip to main content
15,892,059 members
Home / Discussions / C#
   

C#

 
GeneralRe: [Msg Deleted] Pin
Tom Wright9-Sep-05 11:56
Tom Wright9-Sep-05 11:56 
GeneralRe: [Msg Deleted] Pin
Judah Gabriel Himango9-Sep-05 19:17
sponsorJudah Gabriel Himango9-Sep-05 19:17 
GeneralRe: [Msg Deleted] Pin
Tom Wright9-Sep-05 12:17
Tom Wright9-Sep-05 12:17 
GeneralRe: [Msg Deleted] Pin
Judah Gabriel Himango9-Sep-05 19:17
sponsorJudah Gabriel Himango9-Sep-05 19:17 
GeneralRe: XML deserializer question Pin
Tom Wright9-Sep-05 11:42
Tom Wright9-Sep-05 11:42 
GeneralRe: XML deserializer question Pin
S. Senthil Kumar9-Sep-05 22:44
S. Senthil Kumar9-Sep-05 22:44 
GeneralRe: XML deserializer question Pin
Tom Wright10-Sep-05 4:48
Tom Wright10-Sep-05 4:48 
QuestionGenerics and pointers Pin
kippolito9-Sep-05 9:46
kippolito9-Sep-05 9:46 
I am trying to implement a generic class, where the Generic type is a primitive type (uint, double, etc.). The class has a member variable that is an array of the generic type. In a member method, I want to access the array using pointers, but the compiler gives me the error:

Cannot take the address of, get the size of, or declare a pointer to a managed type ('T')
Is there any way to constrain the generic to be for a primitive type? Or is there any other workaround to accomplish this goal? Confused | :confused:

Below is the pseudo-code.
Thanks in advance!

class Image<T><br />
{<br />
     T _pixels[];<br />
<br />
     public Image<T> Cut(int top, int left, int width, int height)<br />
     {<br />
          unsafe<br />
          {<br />
               fixed(T* p = _pixels) // this is the line that produces the error!<br />
               {<br />
                     ...<br />
               }<br />
          }<br />
     }<br />
}


Kim
AnswerRe: Generics and pointers Pin
Judah Gabriel Himango9-Sep-05 10:23
sponsorJudah Gabriel Himango9-Sep-05 10:23 
Questionstatusbar Pin
xilefxilef9-Sep-05 7:59
xilefxilef9-Sep-05 7:59 
AnswerRe: statusbar Pin
miah alom9-Sep-05 8:05
miah alom9-Sep-05 8:05 
GeneralRe: statusbar Pin
xilefxilef9-Sep-05 8:11
xilefxilef9-Sep-05 8:11 
GeneralRe: statusbar Pin
miah alom9-Sep-05 8:32
miah alom9-Sep-05 8:32 
GeneralRe: statusbar Pin
xilefxilef9-Sep-05 8:47
xilefxilef9-Sep-05 8:47 
GeneralRe: statusbar Pin
miah alom9-Sep-05 9:50
miah alom9-Sep-05 9:50 
GeneralRe: statusbar Pin
xilefxilef9-Sep-05 10:38
xilefxilef9-Sep-05 10:38 
GeneralRe: statusbar Pin
miah alom9-Sep-05 10:44
miah alom9-Sep-05 10:44 
GeneralRe: statusbar Pin
xilefxilef9-Sep-05 10:55
xilefxilef9-Sep-05 10:55 
GeneralRe: statusbar Pin
miah alom9-Sep-05 11:04
miah alom9-Sep-05 11:04 
GeneralRe: statusbar Pin
xilefxilef9-Sep-05 13:24
xilefxilef9-Sep-05 13:24 
QuestionFont in resource Pin
Leyu9-Sep-05 7:22
Leyu9-Sep-05 7:22 
QuestionHow to declare an Array of Pens? Pin
...---...9-Sep-05 6:59
...---...9-Sep-05 6:59 
AnswerRe: How to declare an Array of Pens? Pin
Andy Moore9-Sep-05 7:27
Andy Moore9-Sep-05 7:27 
GeneralRe: How to declare an Array of Pens? Pin
...---...9-Sep-05 7:33
...---...9-Sep-05 7:33 
QuestionDataBinding statusBarPanel Pin
rich_wenger9-Sep-05 6:03
rich_wenger9-Sep-05 6:03 

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.