PC Review


Reply
Thread Tools Rate Thread

how can we do memory allocation using C# need some help

 
 
=?Utf-8?B?TmF2ZWVuIGtvdWw=?=
Guest
Posts: n/a
 
      8th Jun 2005
Sir ,

I am new to c#, I am unable to allocate memory to this structure. can anyone
please tellme how can we allocate memory to this strucutre.

struct matrix
{
public int row_dim;
public int col_dim;
unsafe public double **data;
} ;

Regards

Naveen
 
Reply With Quote
 
 
 
 
Ilya Tumanov [MS]
Guest
Posts: n/a
 
      8th Jun 2005
Since it's a value type, declare a variable of this type, it would allocate
the memory:



matrix m;



If you're trying to port application from C/C++, you should redesign it a
little so you won't need pointers.

If data is an array of doubles, declare an array of doubles:



struct matrix
{
public int row_dim;
public int col_dim;
public double[] data;
} ;



To actually create an array, use this:



m.data = new double[m.row_dim * m.col_dim];



In this case, however, you don't need matrix type at all, just declare
managed array:



double[,] mm;



mm = new double[10,10];



Console.WriteLine ("This array has {0} dimentions.", mm.Rank);



for (int d = 0; d < mm.Rank; d++) {

Console.WriteLine ("Dimention {0} has size of {1}.", d,
mm.GetLength(d));

}



Note you have all the information about array size inside the array.



Best regards,



Ilya


This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/...ramework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).

"Naveen koul" <(E-Mail Removed)> wrote in message
news35C91C0-CB5E-4F9E-940A-(E-Mail Removed)...
> Sir ,
>
> I am new to c#, I am unable to allocate memory to this structure. can
> anyone
> please tellme how can we allocate memory to this strucutre.
>
> struct matrix
> {
> public int row_dim;
> public int col_dim;
> unsafe public double **data;
> } ;
>
> Regards
>
> Naveen



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Memory allocation Pavel Minaev Microsoft C# .NET 0 21st Jul 2008 10:19 AM
VBA memory allocation =?Utf-8?B?dml2bWFoYQ==?= Microsoft Excel Programming 12 26th Jun 2007 04:13 PM
XP Memory allocation =?Utf-8?B?SklNX01M?= Windows XP Performance 0 16th Dec 2005 11:41 AM
Memory allocation Mike Piron Windows XP General 1 4th Oct 2003 04:02 AM
Re: Memory Allocation NuT CrAcKeR Microsoft Windows 2000 0 11th Sep 2003 02:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:36 PM.