passing a struct with an array by reference
- From: abhiM <abhi.menon@xxxxxxxxx>
- Date: 3 May 2007 09:53:30 -0700
I have a struct that has an array in it. I need to assign space to the
array in a function and pass the corresponding struct by reference to
another function so that it can store values into the array. When I
try it with the following code i get these errors
1. Use of possibly unassigned field 'micData'
2. The out parameter 'rem' must be assigned to before control leaves
the current method
Could someone point out how to do this and what I am doing wrong. Any
help is greatly appreciated.
---------CODE-----------
Class X{
public struct micDataReturn
{
public double[] micData;//data from the microphone
public double noiseValue;//noise in dB of the data
}
public X()
{
}
public void getData(out micDataReturn rem)
{
try{
rem.micData[0] = 0;
rem.micData[1] = 0;
rem.micData[2] = 0;
}
catch(Exception e)
{
}
}
static void main()
{
X myx = new X();
micDataReturn res = new micDataReturn();
res.micData = new double[10];
X.getData(out res)
}
}
-------------------
Thanks in advance.
.
- Follow-Ups:
- Re: passing a struct with an array by reference
- From: Göran Andersson
- Re: passing a struct with an array by reference
- From: Nicholas Paldino [.NET/C# MVP]
- Re: passing a struct with an array by reference
- From: Alberto Poblacion
- Re: passing a struct with an array by reference
- Prev by Date: Re: int is out of scope???
- Next by Date: CodeDOM Delegate
- Previous by thread: Re: int is out of scope???
- Next by thread: Re: passing a struct with an array by reference
- Index(es):
Relevant Pages
|
Loading