Click here to Skip to main content
15,915,160 members
Home / Discussions / C#
   

C#

 
AnswerRe: SQL Query Pin
Guffa26-Feb-06 8:16
Guffa26-Feb-06 8:16 
GeneralRe: SQL Query Pin
Colin Angus Mackay26-Feb-06 12:00
Colin Angus Mackay26-Feb-06 12:00 
GeneralRe: SQL Query Pin
Guffa26-Feb-06 23:01
Guffa26-Feb-06 23:01 
GeneralRe: SQL Query Pin
Colin Angus Mackay26-Feb-06 23:09
Colin Angus Mackay26-Feb-06 23:09 
GeneralRe: SQL Query Pin
Guffa26-Feb-06 23:33
Guffa26-Feb-06 23:33 
GeneralRe: SQL Query Pin
Colin Angus Mackay26-Feb-06 23:37
Colin Angus Mackay26-Feb-06 23:37 
GeneralRe: SQL Query Pin
Colin Angus Mackay26-Feb-06 12:04
Colin Angus Mackay26-Feb-06 12:04 
QuestionFixed pointers and generics Pin
Lawx0126-Feb-06 5:21
Lawx0126-Feb-06 5:21 
Hi everyone,

I am trying to migrate a source code from C++ to C#. This code deals with computer graphics and image filtering. It needs to be efficient, this explain why I use some low level programmation in C#.

I need to find a way to create a generic class that represent an array of whatever (this array will mostly be used to represent pixels). This class will then allow me to access any data in a width * height grid of data.
But it gets intricate when I try to get a pointer on my generic type. Here is a sample:

class Field<anyType>
{
private int nx, ny;
private anyType[] data;

public unsafe Field(int x, int y)
{
nx = x;
ny = y;

if (nx * ny != 0)
{
data = new anyType[nx * ny];
}
}

// return the anyType value located at (i, j)
public unsafe anyType Value(int parameter)
{
i = (i < 0) ? -i : (i >= nx) ? 2 * nx - i - 1 : i;
j = (j < 0) ? -j : (j >= ny) ? 2 * ny - j - 1 : j;

fixed(<b>anyType* v = data</b>) //this does not compile, see error below
{
return (anyType) *(v + j * nx + i);
}
}

}

But the compilator does not like it, it says:
<i>Cannot take the address of, get the size of, or declare a pointer to a managed type ('anyType')</i>
about the bolded line.
So what? is it impossible to get a pointer on a managed object. I thought it was the goal of the fixed statement to give possibility to use pointer on any object.
I know that I could also simply use data[j*nx+i] but anyhow, I will need this pointer later on for other purpose.

Every good ideas is welcome Smile | :)




Lawrence
AnswerRe: Fixed pointers and generics Pin
leppie26-Feb-06 7:08
leppie26-Feb-06 7:08 
QuestionHow to use the result programed in visual C# in my visual C++ project? Pin
sharkmouse26-Feb-06 3:13
sharkmouse26-Feb-06 3:13 
QuestionNo Article Found for Microphone Voice Recording Pin
emran83426-Feb-06 2:05
emran83426-Feb-06 2:05 
AnswerRe: No Article Found for Microphone Voice Recording Pin
mav.northwind26-Feb-06 2:33
mav.northwind26-Feb-06 2:33 
QuestionProxy Pin
manmoona25-Feb-06 23:53
manmoona25-Feb-06 23:53 
QuestionDefault CUT- COPY - PASTE Pin
emran83425-Feb-06 23:38
emran83425-Feb-06 23:38 
GeneralRe: Default CUT- COPY - PASTE Pin
Guffa26-Feb-06 0:42
Guffa26-Feb-06 0:42 
GeneralRe: Default CUT- COPY - PASTE Pin
emran83426-Feb-06 1:18
emran83426-Feb-06 1:18 
GeneralRe: Default CUT- COPY - PASTE Pin
Guffa26-Feb-06 4:45
Guffa26-Feb-06 4:45 
QuestionSQL syntax in a Crystal Report Pin
mostafa_h25-Feb-06 23:03
mostafa_h25-Feb-06 23:03 
Questionhow can mail to my users via my webapplication without any spam or bulk Pin
m.rastgar25-Feb-06 21:38
m.rastgar25-Feb-06 21:38 
GeneralRe: how can mail to my users via my webapplication without any spam or bulk Pin
Guffa25-Feb-06 22:11
Guffa25-Feb-06 22:11 
GeneralRe: how can mail to my users via my webapplication without any spam or bulk Pin
Colin Angus Mackay25-Feb-06 22:19
Colin Angus Mackay25-Feb-06 22:19 
GeneralRe: how can mail to my users via my webapplication without any spam or bulk Pin
m.rastgar26-Feb-06 2:20
m.rastgar26-Feb-06 2:20 
GeneralRe: how can mail to my users via my webapplication without any spam or bulk Pin
Guffa26-Feb-06 4:47
Guffa26-Feb-06 4:47 
QuestionDo SQL Transactions lock the database automatically ? Pin
emran83425-Feb-06 21:37
emran83425-Feb-06 21:37 
AnswerRe: Do SQL Transactions lock the database automatically ? Pin
Colin Angus Mackay25-Feb-06 22:17
Colin Angus Mackay25-Feb-06 22:17 

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.