first off, I am an IT pro trying to dust off the cobwebs of programming in a
Master degree program so please be nice:)
I am trying to pass a system.array object by reference to a procedure (or
class) and keep getting the compile error "an object reference is required
for the nonstatic field, method, or property... (you know the rest) .. please
look at my code and tell me why my pass by reference is not working
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
try
{
Array arrayHeap = Array.CreateIns tance(typeof(in t),0);
// THIS SYSTEM.ARRAY WILL RESIZE and HAVE Array.Length > 1
arrayHeap = Class1.Collect_ InputFiles(sInp utFile1, sInputFile2, arrayHeap);
//****THIS IS MY PROBLEM STATEMENT
Heapify(ref arrayHeap,array Heap.Length);
}
catch(Exception e)
{
Console.WriteLi ne("exception " + e.ToString());
}
}
public void Heapify(ref System.Array tempHeap, int n)
{
Console.WriteLi ne("Begin Heapify");
try
{
Console.WriteLi ne("i/2 will be =" + n/2);
for (int i = n/2; i >= 1; i--)
{
Console.WriteLi ne("Heapify : Loop #" + i.ToString());
//****I WANT TO STILL REFERENCE THE SAME ARRAY HERE
SiftDown(ref tempHeap,i,n);
}
}
catch (Exception e)
{
Console.WriteLi ne("exception " + e.ToString());
}
}
public void SiftDown(Array arrayHeap, int i , int n)
{
try
{
int temp = Convert.ToInt32 (arrayHeap.GetV alue(i-1));
while (2*i <= n)
{
int child = 2 * i;
if ((child < n)
&& (Convert.ToInt3 2(arrayHeap.Get Value(child)) >
Convert.ToInt32 (arrayHeap.GetV alue(child-1))))
{
child = child + 1;
}
if (Convert.ToInt3 2(arrayHeap.Get Value(child-1)) > temp)
{
arrayHeap.SetVa lue(Convert.ToI nt32
arrayHeap.GetVa lue (child-1)),i-1);
}
else
{
break;
}
i = child;
}
arrayHeap.SetVa lue(temp, i-1);
}
catch(Exception e)
{
Console.WriteLi ne("exception " + e.ToString());
}
} 0 1597 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Morgan |
last post by:
I have read much posts on the argument but no one
clearly says if this operation is possible or not.
Simply I have a routine which reads from a text
file some integer arrays (1 or 2D).
The first array in the file has known dimension,
but it contains the dimensions (so unknown at
compile time) of all the other arrays.
So I can allocate memory only after reading the
|
by: wilson |
last post by:
Dear all,
In this time, I want to pass array to function.
What should I declare the parameter in the function?i
int array or int array? Which one is correct?
/********************************************************
Below is my code:
********************************************************/
|
by: Ekim |
last post by:
hello,
I'm allocating a byte-Array in C# with byte byteArray = new byte;
Now I want to pass this byte-Array to a managed C++-function by reference,
so that I'm able to change the content of the byteArray and afterwards see
the changes in C#.
(if you wanna know more details: the goal is to write the content of an
existing char-array in c++ precisely into the passed byteArray, so that
after the function has proceded the content of the...
|
by: Augusto Cesar |
last post by:
Hello people.
How can I Pass ASP Array variable to Javascript;
I´m to trying this:
<script language="JavaScript">
var x = new Array(10);
|
by: Anaro |
last post by:
Greetings
This is all in VB.net 2005
I am trying to make a programme that will take in a completed survey and then store that survery object within an array.
Currently i know my Surveyclass works and that my array works but when i try to use a function to pass then array from the main form to the survey input form it doesnt seem to store anything in the array.
This is the code for my main form that opens apon running and is where i...
| |
by: venkatagmail |
last post by:
I have problem understanding pass by value and pass by reference and
want to how how they are or appear in the memory:
I had to get my basics right again. I create an array and try all
possible ways of passing an array. In the following code, fun1(int
a1) - same as fun1(int* a1) - where both are of the type passed by
reference. Inside this function, another pointer a1 is created whose
address &a1 is different from that of the passed...
|
by: vipinsoni |
last post by:
Hi all,
I am stucked with a problem. I have to paas a System.Array of object to my unmanaged C code as a void*
I have a class of 'PointZ' which stores x, y,z coordinate and have some methods.I created an System.Array of million of points which contain these point information. I control the size of array on runtime while storing the data into it.
in c# here is my array declaration--
public static System.Array pointRecordsArray =...
|
by: =?Utf-8?B?U3dhcHB5?= |
last post by:
Can anyone suggest me to pass more parameters other than two parameter for
events like the following?
Event:
Onbutton_click(object sender, EventArgs e)"
Event handler:
button.Click += new EventHandler(Onbutton_click);
I want to pass more information related that event. & want to use that
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms.
Here is a newbie mistake that I found myself doing (as a newbie), and
that even a master programmer, the guru of this forum, Jon Skeet,
missed! (He knows this I'm sure, but just didn't think this was my
problem; LOL, I am needling him)
If...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |